DDL AND DML COMMANDS

 


DDL (Data Definition Language)

DDL or Data Definition Language actually consists of the SQL commands that can be used to define the database schema. It simply deals with descriptions of the database schema and is used to create and modify the structure of database objects in the database.

DDL is a set of SQL commands used to create, modify, and delete database structures but not data. These commands are normally not used by a general user, who should be accessing the database via an application.

List of DDL Commands:

Here are all the main DDL (Data Definition Language) commands along with their syntax:

CommandDescriptionSyntax
CREATECreate database or its objects (table, index, function, views, store procedure, and triggers)CREATE TABLE table_name (column1 data_type, column2 data_type, ...);
DROPDelete objects from the databaseDROP TABLE table_name;
ALTERAlter the structure of the databaseALTER TABLE table_name ADD COLUMN column_name data_type;
TRUNCATERemove all records from a table, including all spaces allocated for the records are removedTRUNCATE TABLE table_name;
COMMENTAdd comments to the data dictionaryCOMMENT 'comment_text' ON TABLE table_name;
RENAMERename an object existing in the databaseRENAME TABLE old_table_name TO new_table_name;


DML (Data Manipulation Language)

The SQL commands that deal with the manipulation of data present in the database belong to DML or Data Manipulation Language and this includes most of the SQL statements. 

It is the component of the SQL statement that controls access to data and to the database. Basically, DCL statements are grouped with DML statements.

List of DML commands

Here are all the main DML (Data Manipulation Language) commands along with their syntax:

CommandDescriptionSyntax
INSERTInsert data into a tableINSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...);
UPDATEUpdate existing data within a tableUPDATE table_name SET column1 = value1, column2 = value2 WHERE condition;
DELETEDelete records from a database tableDELETE FROM table_name WHERE condition;
LOCKTable control concurrencyLOCK TABLE table_name IN lock_mode;
CALLCall a PL/SQL or JAVA subprogramCALL procedure_name(arguments);
EXPLAIN PLANDescribe the access path to dataEXPLAIN PLAN FOR SELECT * FROM table_name;

Post a Comment

0 Comments