Sunday 27 August 2017

Different types of statement in SQL

DDL

Data Definition Language statements are used to define the database structure or schema. Examples:
Ø  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. Examples:
Ø  SELECT - retrieve data from the a database
Ø  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
Ø  CALL - call a PL/SQL or Java subprogram
Ø  EXPLAIN PLAN - explain access path to data
Ø  LOCK TABLE - control concurrency

DCL

Data Control Language statements are generally used to provide control/access/privileges to user over database. Examples:
Ø  GRANT - gives user's access privileges to database
Ø  REVOKE - withdraw access privileges given with the GRANT command

TCL

Transaction Control statements are used to manage the changes made by DML statements. It allows statements to be grouped together into logical transactions. Examples:
Ø  COMMIT - save work done
Ø  SAVEPOINT - identify a point in a transaction to which you can later roll back
Ø  ROLLBACK - restore database to original state
Ø  SET TRANSACTION - Change transaction options like isolation level and what rollback segment to use

No comments:

Post a Comment

If you have any doubt, please let me know.

Popular Posts