Structured Query language DDL Commands
lets explore the Data Definition Language commands in SQL

Feb 2, 2025
·
10
min read
Data Definition Language commands in SQL are used to define the structure of the Database.There is a fixed syntax for describing the data.These commands helps organizing the data in the Database.
There are five commands which fall under this category:
CREATE
DROP
ALTER
TRUNCATE
RENAME
lets see each command one by one.
CREATE
CREATE
is used to databse objects whether they are tables , schemas and indexex.
Creating a Databse
CREATE DATABASE college;

it will create a database named college;
Creating a table inside college databse
CREATE TABLE college.students (
id INT PRIMARY KEY,
name VARCHAR(50),
age INT
);

This command will create students table inside college database.
DROP
DROP
command delete the entire object permanently. The database or table will not be present after that.
Dropping a table
DROP TABLE college.students;

Dropping the Database
DROP DATABSE collge;

ALTER
ALTER
is used to modify existing databse tables i.e (adding or deleting columns in a table).
ALTER TABLE college.students ADD COLUMN email VARCHAR(100);
it will add email column in students table.

TRUNCATE
TRUNCATE
remove the data from the table , but it keeps the structure i.e we do not have to create table again we just have to insert data into it.
TRUNCATE TABLE college.students;
After this command all the records from student table will be deleted.
RENAME
This RENAME
command is used to rename the table.
RENAME TABLE students TO allstudents;