Common SQL Commands

SQL commands are divided into categories, the two main ones being Data Manipulation Language (DML) commands and Data Definition Language (DDL) commands. DML commands deal with data, either retrieving it or modifying it to keep it up-to-date. DDL commands create or change tables and other database objects such as views and indexes.

A list of the more common DML commands follows:

  • SELECT — used to query and display data from a database. The SELECT statement specifies which columns to include in the result set. The vast majority of the SQL commands used in applications are SELECT statements.
  • INSERT — adds new rows to a table. INSERT is used to populate a newly created table or to add a new row (or rows) to an already-existing table.
  • DELETE — removes a specified row or set of rows from a table
  • UPDATE — changes an existing value in a column or group of columns in a table

The more common DDL commands follow:

  • CREATE TABLE — creates a table with the column names the user provides. The user also needs to specify a type for the data in each column. Data types vary from one RDBMS to another, so a user might need to use metadata to establish the data types used by a particular database. CREATE TABLE is normally used less often than the data manipulation commands because a table is created only once, whereas adding or deleting rows or changing individual values generally occurs more frequently.
  • DROP TABLE — deletes all rows and removes the table definition from the database. A JDBC API implementation is required to support the DROP TABLE command as specified by SQL92, Transitional Level. However, support for the CASCADE and RESTRICT options of DROP TABLE is optional. In addition, the behavior of DROP TABLE is implementation-defined when there are views or integrity constraints defined that reference the table being dropped.
  • ALTER TABLE — adds or removes a column from a table. It also adds or drops table constraints and alters column attributes

Related Posts:

2 Responses

Denny May 28, 2008 at 5:16 am

Using SQL Plus, I am trying to add table and column comments in Oracle. The comment text contains things like ‘, “, &, carriage returns, etc. I know there is a command to enter in SQL Plus prior to running the comment scripts, but I don’t remember what that command is to allow Oracle to accept the invalid characters. Do you know what that command is?

javatechie May 28, 2008 at 5:16 am

I dont know much about oracle. I found this, see if it is useful for you
1) TRANSLATE (for Oracle <= 9i)
2) regexp_like (for Orcale 10g and later)

Comments are closed.