SQL commands
• SQL commands are very used to interact with the database.
• These commands allow users to perform various actions on a database.
• SQL commands are like instructions to a table. It is used to interact with the database
with some operations.
• SQL can perform various tasks like creating a table, adding data to tables, dropping the
table, modifying the table, set permission for users.
These SQL commands are mainly categorized into five categories:
• DDL – Data Definition Language
• DQL – Data Query Language
• DML – Data Manipulation Language
• DCL – Data Control Language
• TCL – Transaction Control Language
DDL (Data Definition Language)
DDL (Data Definition Language):.DDL or Data Definition Language actually consists of the
SQL commands that can be used to define the database schema.
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.
Command Description Syntax
CREATE Create database or its objects CREATE TABLE table_name
(table, index, function, views, (column1 data_type, column2
data_type, ...);
store procedure, and triggers)
DROP Delete objects from the database DROP TABLE table_name;
ALTER Alter the structure of the ALTER TABLE table_name
database ADD COLUMN column_name
data_type;
TRUNCATE Remove all records from a table, TRUNCATE TABLE
including all spaces allocated table_name;
for the records are removed
COMMENT Add comments to the data COMMENT 'comment_text'
dictionary ON TABLE table_name;
RENAME Rename an object existing in the RENAME TABLE
database old_table_name TO
new_table_name;
DML(Data Manipulation Language)
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
Command Description Syntax
INSERT Insert data into a table INSERT INTO table_name (column1, column2,
...) VALUES (value1, value2, ...);
UPDATE Update existing data UPDATE table_name SET column1 = value1,
within a table column2 = value2 WHERE condition;
DELETE Delete records from a DELETE FROM table_name WHERE condition;
database table
LOCK Table control LOCK TABLE table_name IN lock_mode;
concurrency
CALL Call a PL/SQL or CALL procedure_name(arguments);
JAVA subprogram
EXPLAIN Describe the access EXPLAIN PLAN FOR SELECT * FROM
PLAN path to data table_name;