Sql Commands - (DDL (Data Definition Language), DML (Data Manipulation Language), DCL (Data Control Language), TCL (Transaction Control Language)

SQL language is divided into four types of primary language statements: DML, DDL, DCL, and TCL. Using these statements, we can define the structure of a database by creating and altering database objects, and we can manipulate data in a table through updates or deletions. We also can control which user can read/write data or manage transactions to create a single unit of work.
The four main categories of SQL statements are as follows:



DDL (DataDefinition Language) command is used for defining the structure of the Data. DDL Statements are auto-commit.

CREATE                   -      to create objects in the database
ALTER                      -     alters the structure of the database
DROP                        -     delete objects from the database
TRUNCATE              -     remove all records from a table, including all spaces
                                         allocated for the records are removed
COMMENT              -     add comments to the data dictionary
RENAME                  -     rename an object


DML (data manipulation Language) statements are used for managing
data within schema objects.
  • DML Statements can be rollbacked.
  • DML Statements can’t be roll backed When DDL Statement Executed immediately after the DML statement.
Command
Description
INSERT                         -
Insert data into a table.
UPDATE                        -
Updates existing data within a table.
DELETE                        -
Deletes all records from a table, the space for the records
remain
 DQL - Data Query Language:

Command
Description
SELECT                         -
Retrieves certain records from one or more tables.


Command
Description
GRANT                           -
Gives user's access privileges to a database.
REVOKE                        -
Withdraw access privileges given with the GRANT
command.

TCL - (Transaction Control Language) 

 (Transaction Control Language) Manages the changes made by DML 
statements. These commands allow statements to be grouped together into logical transactions.

Command
Description
COMMIT           -    Save work done.
SAVEPOINT      -    Identify a point in a transaction to which you can later roll back.
ROLLBACK      -    Restore database to original since the last COMMIT.




1 comment: