Data Definition Language in Structured Query Language (SQL) :
- Data Definition Language is also known as “Data Description Language”.
- Data Definition Language is used to define Data and Objects in a Database.
- Data Definition Language Commands are used to make entries in the Data Dictionary.
- Data Definition Language is used to define -
- Data and Objects in Database
- Tables in a Database
- Database Structure
- 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
Command | Explanation |
---|---|
Create Database | Used to Create Database |
Drop Database | Delete Complete Database (including all tables) / Drop Database |
Create Table | Creating table inside database |
Drop Table | To delete any table from the database |
Create Index | Used to create index |
Grant | Used to grant access privileges to user |