In this article, we will discuss the overview of DDL commands and will understand DDL commands like create, alter, truncate, drop. We will cover each command syntax with the help of an example for better understanding. Let’s discuss it one by one.
Overview :
Data Definition Language(DDL) is a subset of SQL and a part of DBMS(Database Management System). DDL consist of Commands to commands like CREATE, ALTER, TRUNCATE and DROP. These commands are used to create or modify the tables in SQL.
DDL Commands :
In this section, We will cover the following DDL commands as follows.
- Create
- Alter
- truncate
- drop
- Rename
Let’s discuss it one by one.
Command-1 :
CREATE :
This command is used to create a new table in SQL. The user has to give information like table name, column names, and their datatypes.
Syntax –
CREATE TABLE table_name
(
column_1 datatype,
column_2 datatype,
column_3 datatype,
....
);
Example –
We need to create a table for storing Student information of a particular College. Create syntax would be as below.
CREATE TABLE Student_info
(
College_Id number(2),
College_name varchar(30),
Branch varchar(10)
);
Command-2 :
ALTER :
This command is used to add, delete or change columns in the existing table. The user needs to know the existing table name and can do add, delete or modify tasks easily.
Syntax –
Syntax to add a column to an existing table.
ALTER TABLE table_name
ADD column_name datatype;
Example –
In our Student_info table, we want to add a new column for CGPA. The syntax would be as below as follows.
ALTER TABLE Student_info
ADD CGPA number;
Command-3 :
TRUNCATE :
This command is used to remove all rows from the table, but the structure of the table still exists.
Syntax –
Syntax to remove an existing table.
TRUNCATE TABLE table_name;
Example –
The College Authority wants to remove the details of all students for new batches but wants to keep the table structure. The command they can use is as follows.
TRUNCATE TABLE Student_info;
Command-4 :
DROP :
This command is used to remove an existing table along with its structure from the Database.
Syntax –
Syntax to drop an existing table.
DROP TABLE table_name;
Example –
If the College Authority wants to change their Database by deleting the Student_info Table.
DROP TABLE Student_info;
Command -5
RENAME:
It is possible to change name of table with or without data in it using simple RENAME command.
We can rename any table object at any point of time.
Syntax –
RENAME TABLE <Table Name> To <New_Table_Name>;
Example:
If you want to change the name of the table from Employee to Emp we can use rename command as
RENAME TABLE Employee To EMP;
Dreaming of M.Tech in IIT? Get AIR under 100 with our GATE 2026 CSE & DA courses! Get flexible weekday/weekend options, live mentorship, and mock tests. Access exclusive features like All India Mock Tests, and Doubt Solving—your GATE success starts now!
Similar Reads
SQL Commands | DDL, DQL, DML, DCL and TCL Commands
SQL commands are essential for managing databases effectively. These commands are divided into categories such as Data Definition Language (DDL), Data Manipulation Language (DML), Data Control Language (DCL), Data Query Language (DQL), and Transaction Control Language (TCL). In this article, we will explain the different types of SQL commands, incl
6 min read
Adding & Editing & Deleting & Searching Records with Data Form
Overview :To manage records using Data Form, it will give you the following options like adding data, deleting data, searching data using data from. Let's discuss Adding, Deleting, Searching Records with Data Form as follows. Steps to implement operations with data form :Here, we will discuss how you can add, delete and search data using data form
4 min read
Difference Between DDL and DML in DBMS
DDL is a Data Definition Language that is used to define data structures. For example: creating a table, and altering a table are instructions in SQL. DML is a Data Manipulation Language that is used to manipulate data itself. For example: insert, update, and delete are instructions in SQL. Data Definition Language DDL is used to specify a database
3 min read
Difference between DDL and TCL
Prerequisite – SQL Commands 1 Data Definition Language (DDL) is a set of SQL (Structured Query Language) commands used to create, modify, and delete database objects such as tables, indexes, views, and constraints. DDL statements are used to define the schema or structure of a database, including its data types, relationships between tables, and r
2 min read
SQL | DDL, DML, TCL and DCL
Data Definition Language (DDL), Data Manipulation Language (DML), Transaction Control Language (TCL), and Data Control Language (DCL) form the backbone of SQL. Each of these languages plays a critical role in defining, managing, and controlling data within a database system, ensuring both structural integrity and user access control.In this article
6 min read
DDL Full Form - Data Definition Language
DDL stands for Data Definition Language. These are the commands that are used to change the structure of a database and database objects. For example, DDL commands can be used to add, remove, or modify tables within a database.In this article, We will learn about the DDL Full Form by understanding various examples and so on.What is DDL?DDL actually
7 min read
Even Odd method & Winding number Method-Inside & Outside Test of a Polygon
Introduction :A polygon may be represented as a number of line segments connected, end to form a closed figure.Polygons can be represented in two ways - (i) outline from using move commands and (ii) as a solid objects by setting the pixels high inside the polygon including pixels on the boundary. To determine a point lies inside a polygon or not, i
4 min read
Difference Between Syntax and Semantics
Syntax: It refers to the rules and regulations for writing any statement in a programming language like C/C++.It does not have to do anything with the meaning of the statement.A statement is syntactically valid if it follows all the rules.It is related to the grammar and structure of the language.Semantics: It refers to the meaning associated with
4 min read
ES6 Top features and syntax
ES6 or as it is officially called: ECMAScript2015 is a new JavaScript implementation and is arguably the hottest topic in the JS developer's conventions and meetups why it should not be: JavaScript rules the web and is gaining a foothold in every other field possible, be it robotics(nodebots), desktop applications(using ion framework), chatbots, et
3 min read
SQLite Statements and Syntax
SQLite is a self-contained, file-based SQL database that follows a specific syntax. Statements in SQLite are used to query the database and are essential for database management. Every statement follows a fixed syntax in SQLite. In this guide, we will look at some important SQLite statements and syntaxes. We have divided the statements into several
3 min read