Wednesday, October 15, 2014

COMPONENTS OF SQL



DDL (Data Definition Language) : It 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 as every DDL command implicitly issues a COMMIT command to the database.

DML (Data Manipulation Language) : It is the area of SQL that allows changing data within the database.

DCL (Data Control Language) : It is the component of SQL statement that control access to data and to the database. Occasionally DCL statements are grouped with DML statements.

DQL (Data Query Language) : It is the component of SQL statement that allows getting data from the database and imposing ordering upon it. In includes the SELECT statement. This command is the heart of SQL. It allows getting the data out of the database perform operations with it. When a SELECT is fired against a table or tables the result is compiled into a further temporary table, which is displayed or perhaps received by the program i.e. a front end.

Examples of DDL, DML and DCL commands

DDL: Data Definition Language statements

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
GRANT         Gives user's access priVileges to database
REVOKE      Withdraw access privileges given with the GRANT command

DML: Data Manipulation Language statements

Examples:
            INSERT         Insert data into a table
            UPDATE       Updates existing datawithin a table
            DELETE       Deletes all records from a table, the space for the records remain
            CALL             Call a PUS or Java subprogram
            EXPLAIN PLAN     Explain access path to data
            LOCK TABLE         Control concurrency

DCL: Data Control Language statements

Examples:
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
SET TRANSACTION         Change transaction options like what rollback segment to use,
GRANT / REVOKE            Grant or take back permissions to or from the oracle users

DQL: Data Query Language statement

Examples:
SELECT Retrieve data from the a database

No comments: