SlideShare a Scribd company logo
2
Most read
3
Most read
4
Most read
Program No. # 01
Object :- Write SQL Queries for DDL (Data Definition Language) Statement.
DDL Commands :-
 CREATE Query
 ALTER Query
 TRUNCATE Query
 RENAME Query
 DROP Query
1. CREATE Command :- CREATE is a DDL SQL Command used to create a table or a
database in relational database management system.
 Creating a Database:- To create a database in RDBMS, Create command is
used.Following is the syntax:-
 Example for creating Database:-
 Creating a Table:- CREATE command can also be used to create tables. Now
when we create a table. We have to specify the names and datatypes of
various columns in the Create command itself. Following is the syntax:-
CREATE DATABASE DATABASE_NAME;
CREATE DATABASE DBMS;
CREATE TABLE TABLE_NAME
( Column_name1 datatype(size),
Column_name2 datatype(size),
Column_name3 datatype(size),
Column_name4 datatype(size) );
 Example for creating Table:-
2. Alter Command :- ALTER command is used for altering the table structure, such as,
 To add a column to an existing table.
 To change datatype of any column or to modify its size.
 To drop a column from table.
 Adding new columns :- Using ALTER command we can add single or multiple
new columns to any existing table. Following is the syntax:-
 Here is an Example for this :-
CREATE TABLE Student (
Roll_No. INT(15),
Name CHAR(50),
Branch CHAR(25) );
ALTER TABLE table_name ADD (
Column_name1 datatype(size),
Column_name2 datatype(size),
Column_name3 datatype(size) );
ALTER TABLE Student ADD (
Father_Name CHAR(60),
Mother_Name CHAR(60),
Address CHAR(100)
);
 Modifying an existing column :- ALTER command can also be used to modify
datatype of any existing column. Following is the syntax:-
 Here is an Example for this:-
3. TRUNCATE Command :- TRUNCATE command removes all the records from a table,
But this command will not destroy the table’s structure. When we use TRUNCATE
command on a table its (auto-increment) primary key is also initialized. Following is
its syntax:-
 Here is an Exapmle :-
4. RENAME Query:- RENAME command is used to set a new name for any existing
table. Following is the Syntax:-
 Here is an Example :-
ALTER TABLE table_name MODIFY
Column_name datatype (Size);
ALTER TABLE STUDENT MODIFY
Address VARCHAR (200) ;
TRUNCATE TABLE table_name ;
TRUNCATE TABLE STUDENT ;
RENAME TABLE STUDENT to STUDENT_INFO ;
RENAME TABLE old_table_name to new_table_name ;
5. DROP Command :- DROP command completely removes a table from the database.
This command will destroy the table structure and the data stored in it. Following is
its Syntax:-
 Here is an Example:-
DROP command can also be used to delete the complete database. Following is its
Syntax:-
 Here is an Example :-
DROP TABLE table_name ;
DROP TABLE STUDENT ;
DROP DATABASE database_name ;
DROP DATABASE DBMS;
SQL Queries - DDL Commands
SQL Queries - DDL Commands
SQL Queries - DDL Commands
SQL Queries - DDL Commands
SQL Queries - DDL Commands
SQL Queries - DDL Commands
SQL Queries - DDL Commands

More Related Content

What's hot (20)

PPTX
database language ppt.pptx
Anusha sivakumar
 
PPTX
Attributes
Pooja Dixit
 
PPTX
Linked list
KalaivaniKS1
 
PPTX
Group By, Order By, and Aliases in SQL
MSB Academy
 
PPTX
set operators.pptx
Anusha sivakumar
 
PDF
Create table
Nitesh Singh
 
PPTX
Stacks and Queue - Data Structures
Dr. Jasmine Beulah Gnanadurai
 
PPTX
SQL JOIN
Ritwik Das
 
PPTX
Abstract Data Types
karthikeyanC40
 
PPT
Joins in SQL
Vigneshwaran Sankaran
 
PDF
View & index in SQL
Swapnali Pawar
 
PPT
Abstract data types
Poojith Chowdhary
 
PPTX
contiguous memory allocation.pptx
Rajapriya82
 
PPTX
1.4 data independence
BHARATH KUMAR
 
PPTX
Oracle: Joins
oracle content
 
PDF
Addressing modes in computer organization
bushraphd2022
 
PPTX
Binary Tree Traversal
Dhrumil Panchal
 
PPTX
Sparse matrix and its representation data structure
Vardhil Patel
 
PDF
Dbms Notes Lecture 9 : Specialization, Generalization and Aggregation
BIT Durg
 
database language ppt.pptx
Anusha sivakumar
 
Attributes
Pooja Dixit
 
Linked list
KalaivaniKS1
 
Group By, Order By, and Aliases in SQL
MSB Academy
 
set operators.pptx
Anusha sivakumar
 
Create table
Nitesh Singh
 
Stacks and Queue - Data Structures
Dr. Jasmine Beulah Gnanadurai
 
SQL JOIN
Ritwik Das
 
Abstract Data Types
karthikeyanC40
 
Joins in SQL
Vigneshwaran Sankaran
 
View & index in SQL
Swapnali Pawar
 
Abstract data types
Poojith Chowdhary
 
contiguous memory allocation.pptx
Rajapriya82
 
1.4 data independence
BHARATH KUMAR
 
Oracle: Joins
oracle content
 
Addressing modes in computer organization
bushraphd2022
 
Binary Tree Traversal
Dhrumil Panchal
 
Sparse matrix and its representation data structure
Vardhil Patel
 
Dbms Notes Lecture 9 : Specialization, Generalization and Aggregation
BIT Durg
 

Similar to SQL Queries - DDL Commands (20)

PPTX
introdution to SQL and SQL functions
farwa waqar
 
PDF
Sql smart reference_by_prasad
paddu123
 
PDF
Sql smart reference_by_prasad
paddu123
 
PPTX
Introduction to database and sql fir beginers
reshmi30
 
DOCX
unit-5 sql notes.docx
RaviRajput416403
 
PPTX
SQL: Data Definition Language(DDL) command
sonali sonavane
 
PPTX
MySQL Essential Training
HudaRaghibKadhim
 
DOC
SQL
Tuhin_Das
 
PPTX
SQL - DML and DDL Commands
Shrija Madhu
 
DOC
Oracle sql material
prathap kumar
 
PPTX
SQl data base management and design
franckelsania20
 
PPTX
SQL-SHORT-NOTES.pptx
PratheeshKumarN
 
PPT
Creating a database
Rahul Gupta
 
DOCX
COMPUTERS SQL
Rc Os
 
PPTX
Database models and DBMS languages
DivyaKS12
 
PPT
Sql Commands_Dr.R.Shalini.ppt
DrRShaliniVISTAS
 
PPT
mysqlHiep.ppt
webhostingguy
 
PPT
MySQL Database System Hiep Dinh
webhostingguy
 
introdution to SQL and SQL functions
farwa waqar
 
Sql smart reference_by_prasad
paddu123
 
Sql smart reference_by_prasad
paddu123
 
Introduction to database and sql fir beginers
reshmi30
 
unit-5 sql notes.docx
RaviRajput416403
 
SQL: Data Definition Language(DDL) command
sonali sonavane
 
MySQL Essential Training
HudaRaghibKadhim
 
SQL - DML and DDL Commands
Shrija Madhu
 
Oracle sql material
prathap kumar
 
SQl data base management and design
franckelsania20
 
SQL-SHORT-NOTES.pptx
PratheeshKumarN
 
Creating a database
Rahul Gupta
 
COMPUTERS SQL
Rc Os
 
Database models and DBMS languages
DivyaKS12
 
Sql Commands_Dr.R.Shalini.ppt
DrRShaliniVISTAS
 
mysqlHiep.ppt
webhostingguy
 
MySQL Database System Hiep Dinh
webhostingguy
 
Ad

Recently uploaded (20)

PDF
3rd International Conference on Machine Learning and IoT (MLIoT 2025)
ClaraZara1
 
PPTX
Knowledge Representation : Semantic Networks
Amity University, Patna
 
PPTX
Introduction to Internal Combustion Engines - Types, Working and Camparison.pptx
UtkarshPatil98
 
PPT
New_school_Engineering_presentation_011707.ppt
VinayKumar304579
 
PPTX
Numerical-Solutions-of-Ordinary-Differential-Equations.pptx
SAMUKTHAARM
 
PPTX
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
PDF
Electrical Machines and Their Protection.pdf
Nabajyoti Banik
 
PPTX
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 
PDF
Electrical Engineer operation Supervisor
ssaruntatapower143
 
PPTX
Water Resources Engineering (CVE 728)--Slide 4.pptx
mohammedado3
 
PDF
AN EMPIRICAL STUDY ON THE USAGE OF SOCIAL MEDIA IN GERMAN B2C-ONLINE STORES
ijait
 
PPTX
Final Major project a b c d e f g h i j k l m
bharathpsnab
 
PPTX
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
PPTX
MODULE 03 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
PDF
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
PPTX
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 
PDF
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
PDF
Viol_Alessandro_Presentazione_prelaurea.pdf
dsecqyvhbowrzxshhf
 
PPTX
How Industrial Project Management Differs From Construction.pptx
jamespit799
 
PDF
REINFORCEMENT LEARNING IN DECISION MAKING SEMINAR REPORT
anushaashraf20
 
3rd International Conference on Machine Learning and IoT (MLIoT 2025)
ClaraZara1
 
Knowledge Representation : Semantic Networks
Amity University, Patna
 
Introduction to Internal Combustion Engines - Types, Working and Camparison.pptx
UtkarshPatil98
 
New_school_Engineering_presentation_011707.ppt
VinayKumar304579
 
Numerical-Solutions-of-Ordinary-Differential-Equations.pptx
SAMUKTHAARM
 
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
Electrical Machines and Their Protection.pdf
Nabajyoti Banik
 
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 
Electrical Engineer operation Supervisor
ssaruntatapower143
 
Water Resources Engineering (CVE 728)--Slide 4.pptx
mohammedado3
 
AN EMPIRICAL STUDY ON THE USAGE OF SOCIAL MEDIA IN GERMAN B2C-ONLINE STORES
ijait
 
Final Major project a b c d e f g h i j k l m
bharathpsnab
 
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
MODULE 03 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
2025 CGI Congres - Surviving agile v05.pptx
Derk-Jan de Grood
 
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
Viol_Alessandro_Presentazione_prelaurea.pdf
dsecqyvhbowrzxshhf
 
How Industrial Project Management Differs From Construction.pptx
jamespit799
 
REINFORCEMENT LEARNING IN DECISION MAKING SEMINAR REPORT
anushaashraf20
 
Ad

SQL Queries - DDL Commands

  • 1. Program No. # 01 Object :- Write SQL Queries for DDL (Data Definition Language) Statement. DDL Commands :-  CREATE Query  ALTER Query  TRUNCATE Query  RENAME Query  DROP Query 1. CREATE Command :- CREATE is a DDL SQL Command used to create a table or a database in relational database management system.  Creating a Database:- To create a database in RDBMS, Create command is used.Following is the syntax:-  Example for creating Database:-  Creating a Table:- CREATE command can also be used to create tables. Now when we create a table. We have to specify the names and datatypes of various columns in the Create command itself. Following is the syntax:- CREATE DATABASE DATABASE_NAME; CREATE DATABASE DBMS; CREATE TABLE TABLE_NAME ( Column_name1 datatype(size), Column_name2 datatype(size), Column_name3 datatype(size), Column_name4 datatype(size) );
  • 2.  Example for creating Table:- 2. Alter Command :- ALTER command is used for altering the table structure, such as,  To add a column to an existing table.  To change datatype of any column or to modify its size.  To drop a column from table.  Adding new columns :- Using ALTER command we can add single or multiple new columns to any existing table. Following is the syntax:-  Here is an Example for this :- CREATE TABLE Student ( Roll_No. INT(15), Name CHAR(50), Branch CHAR(25) ); ALTER TABLE table_name ADD ( Column_name1 datatype(size), Column_name2 datatype(size), Column_name3 datatype(size) ); ALTER TABLE Student ADD ( Father_Name CHAR(60), Mother_Name CHAR(60), Address CHAR(100) );
  • 3.  Modifying an existing column :- ALTER command can also be used to modify datatype of any existing column. Following is the syntax:-  Here is an Example for this:- 3. TRUNCATE Command :- TRUNCATE command removes all the records from a table, But this command will not destroy the table’s structure. When we use TRUNCATE command on a table its (auto-increment) primary key is also initialized. Following is its syntax:-  Here is an Exapmle :- 4. RENAME Query:- RENAME command is used to set a new name for any existing table. Following is the Syntax:-  Here is an Example :- ALTER TABLE table_name MODIFY Column_name datatype (Size); ALTER TABLE STUDENT MODIFY Address VARCHAR (200) ; TRUNCATE TABLE table_name ; TRUNCATE TABLE STUDENT ; RENAME TABLE STUDENT to STUDENT_INFO ; RENAME TABLE old_table_name to new_table_name ;
  • 4. 5. DROP Command :- DROP command completely removes a table from the database. This command will destroy the table structure and the data stored in it. Following is its Syntax:-  Here is an Example:- DROP command can also be used to delete the complete database. Following is its Syntax:-  Here is an Example :- DROP TABLE table_name ; DROP TABLE STUDENT ; DROP DATABASE database_name ; DROP DATABASE DBMS;