Data Definition Language in Structured Query Language (SQL) :

  1. Data Definition Language is also known as “Data Description Language”.
  2. Data Definition Language is used to define Data and Objects in a Database.
  3. Data Definition Language Commands are used to make entries in the Data Dictionary.
  4. Data Definition Language is used to define -
    • Data and Objects in Database
    • Tables in a Database
    • Database Structure
  5. Generally DDL Commands are used for Data Administration.

Some Commands Used in Data Definition Language [DDL Commands] :

Create Database

In order to create database create command is used.
Syntax :

CREATE DATABASE <database-name> ;

Drop Database

In order to delete or drop database drop command is used.
Syntax :

DROP DATABASE <database-name> ;

Create Table

In order to create table inside database create command is used.
Syntax :

CREATE TABLE <table-name> (
...
);

Sample Example for Creating Table :

CREATE TABLE PERSON (
PERSONID INT,
LNAME VARCHAR(20),
FNAME VARCHAR(20) NOT NULL,
DOB DATE,
PRIMARY KEY(PERSONID)
);

Drop Table

To delete any database table drop command is used.
Syntax :

DROP TABLE <table-name> ;

Alter Table

  • To Add Column to the Database Table
  • To Remove Column From the Database Table
  • To Modify Datatype/Size of Existing Table.

Syntax :

ALTER TABLE <table-name>
ADD <field-name> <data-type>

Summary of Data Definition Language

CommandExplanation
Create DatabaseUsed to Create Database
Drop DatabaseDelete Complete Database (including all tables) / Drop Database
Create TableCreating table inside database
Drop TableTo delete any table from the database
Create IndexUsed to create index
GrantUsed to grant access privileges to user