Data Definition Language – DDL Statement



In previous SQL post we had discussed about Basic SQL Concept and what is SQL Database and SQL Table.

DDL – Data Definition Language


DDL – Data Definition Language contains the commands used to create and destroy database and database objects like tables and columns.

The DDL statement is used to define the structure of database and database object.

After define the structure of Database the administrator use the DML Data Manipulation Language to insert, retrieve and modify the information or data.

DDL Statements used to create and modify the structure of tables and other objects in database.

When we execute the DDL Statement, it takes effect immediately.


Here are the list of DDL Commands :

1. CREATE
The CREATE command is used to create new database in DBMS, and create new table in database. In other word we can say CREATE command used to create new database and table.

CREATE Command Syntax for Database:

CREATE DatabaseName

CREATE School
database name = School

CREATE Command Syntax for Table :

CREATE TABLE Tablename
(
Column1 datatype,
Column2 datatype,
Column3 datatype
)

CREATE TABLE Student
(
ID int,
Name char(20),
City char(30)
)

2. USE
The USE command allows you to specify the database you wish to work with within your DBMS.

The USE Command Syntax:

USE Databasename

USE School

3. ALTER
The ALTER command used to modify the structure of table without deleting.
We can use ADD and MODIFY command with ALTER command.

4. DROP
The DROP command used to remove the database object from DBMS, and delete the table from database.

The DROP Command Syntax:

DROP Databasename
DROP School

DROP TABLE Tablename
DROP TABLE Student

5. TRUNCATE TABLE
The TRUNCATE TABLE command used to delete all the rows/records from entire table.
The TRUNCATE command also remove the index from columns.

The TRUNCATE TABLE Command Syntax:

TRUNCATE TABLE Tablename

TRUNCATE TABLE Student

We will learn all DDL Command in detail with our next article.

Leave a Reply

Your email address will not be published. Required fields are marked *