0% found this document useful (0 votes)
11 views7 pages

DDL Queries

The document provides an overview of Data Definition Language (DDL) in SQL, detailing its purpose in creating and modifying database tables. It outlines four main DDL commands: CREATE, ALTER, TRUNCATE, and DROP, along with their syntax and examples. The examples illustrate how to create a table for student information, add a column, truncate the table, and drop the table entirely.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views7 pages

DDL Queries

The document provides an overview of Data Definition Language (DDL) in SQL, detailing its purpose in creating and modifying database tables. It outlines four main DDL commands: CREATE, ALTER, TRUNCATE, and DROP, along with their syntax and examples. The examples illustrate how to create a table for student information, add a column, truncate the table, and drop the table entirely.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Structure of Presentation

Introduction of DDL Queries


Syntax & DDL Commands
Example of DDL Commands
Introduction of DDL Queries

 Data Definition Language(DDL) is a subset of SQL and a part


of DBMS(Database Management System).

 DDL commands are used to create or modify the tables in SQL.

 DDL commands as follows.

1) Create
2) Alter
3) Truncate
4) Drop
Syntax & DDL Commands
 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));
Continued..
 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;
Continued..
 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;
Continued..
 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;
THANKS

You might also like