This document discusses the four main categories of SQL statements: Data Definition Language (DDL) for defining database schemas, Data Manipulation Language (DML) for managing data, Transaction Control Language (TCL) for managing transactions, and Data Control Language (DCL) for controlling access privileges. It provides examples of common commands for each category, such as CREATE, SELECT, and COMMIT. It also includes examples of using DDL to define a table and DML to query data from a table.
This document discusses the four main categories of SQL statements: Data Definition Language (DDL) for defining database schemas, Data Manipulation Language (DML) for managing data, Transaction Control Language (TCL) for managing transactions, and Data Control Language (DCL) for controlling access privileges. It provides examples of common commands for each category, such as CREATE, SELECT, and COMMIT. It also includes examples of using DDL to define a table and DML to query data from a table.
This document discusses the four main categories of SQL statements: Data Definition Language (DDL) for defining database schemas, Data Manipulation Language (DML) for managing data, Transaction Control Language (TCL) for managing transactions, and Data Control Language (DCL) for controlling access privileges. It provides examples of common commands for each category, such as CREATE, SELECT, and COMMIT. It also includes examples of using DDL to define a table and DML to query data from a table.
This document discusses the four main categories of SQL statements: Data Definition Language (DDL) for defining database schemas, Data Manipulation Language (DML) for managing data, Transaction Control Language (TCL) for managing transactions, and Data Control Language (DCL) for controlling access privileges. It provides examples of common commands for each category, such as CREATE, SELECT, and COMMIT. It also includes examples of using DDL to define a table and DML to query data from a table.
Download as DOCX, PDF, TXT or read online from Scribd
Download as docx, pdf, or txt
You are on page 1of 3
SQL | DDL, DML, TCL and DCL
In this article, we’ll be discussing Data Definition Language, Data
Manipulation Language, Transaction Control Language, and Data Control Language.
Some Commands:
CREATE : to create objects in database ALTER : alters the structure of database DROP : delete objects from database RENAME : rename an objects
Following SQL DDL-statement defines the department table :
create table department (dept_name char(20), building char(15), budget numeric(12,2)); Execution of the above DDL statement creates the department table with three columns – dept_name, building, and budget; each of which has a specific datatype associated with it. DML (Data Manipulation Language) : DML statements are used for managing data with in schema objects. DML are of two types –
1. Procedural DMLs : require a user to specify what data are needed and how to get those data. 2. Declarative DMLs (also referred as Non-procedural DMLs) : require a user to specify what data are needed without specifying how to get those data. Declarative DMLs are usually easier to learn and use than procedural DMLs. However, since a user does not have to specify how to get the data, the database system has to figure out an efficient means of accessing data. Some Commands :
SELECT: retrieve data from the database INSERT: insert data into a table UPDATE: update existing data within a table DELETE: deletes all records from a table, space for the records remain Example of SQL query that finds the names of all instructors in the History department :
select instructor.name from instructor where instructor.dept_name = 'History'; The query specifies that those rows from the table instructor where the dept_name is History must be retrieved and the name attributes of these rows must be displayed. TCL (Transaction Control Language) : Transaction Control Language commands are used to manage transactions in the database. These are used to manage the changes made by DML- statements. It also allows statements to be grouped together into logical transactions. Examples of TCL commands –
COMMIT: Commit command is used to permanently save any transaction into the database. ROLLBACK: This command restores the database to last committed state. It is also used with savepoint command to jump to a savepoint in a transaction. SAVEPOINT: Savepoint command is used to temporarily save a transaction so that you can rollback to that point whenever necessary.
DCL (Data Control Language) : A Data Control Language is a syntax similar to a computer programming language used to control access to data stored in a database (Authorization). In particular, it is a component of Structured Query Language (SQL). Examples of DCL commands :
GRANT: allow specified users to perform specified tasks. REVOKE: cancel previously granted or denied permissions. The operations for which privileges may be granted to or revoked from a user or role apply to both the Data definition language (DDL) and the Data manipulation language (DML), and may include CONNECT, SELECT, INSERT, UPDATE, DELETE, EXECUTE and USAGE. In the Oracle database, executing a DCL command issues an implicit commit. Hence, you cannot roll back the command.