SlideShare a Scribd company logo
1 of 11
Download to read offline
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)

Sql Commands_Dr.R.Shalini.ppt
Sql Commands_Dr.R.Shalini.pptSql Commands_Dr.R.Shalini.ppt
Sql Commands_Dr.R.Shalini.ppt
 
Sql subquery
Sql  subquerySql  subquery
Sql subquery
 
PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts
 
SQL Queries Information
SQL Queries InformationSQL Queries Information
SQL Queries Information
 
Normalization in a Database
Normalization in a DatabaseNormalization in a Database
Normalization in a Database
 
SQL Views
SQL ViewsSQL Views
SQL Views
 
SQL Basics
SQL BasicsSQL Basics
SQL Basics
 
SQL(DDL & DML)
SQL(DDL & DML)SQL(DDL & DML)
SQL(DDL & DML)
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
 
Alter table command
Alter table commandAlter table command
Alter table command
 
Sql – Structured Query Language
Sql – Structured Query LanguageSql – Structured Query Language
Sql – Structured Query Language
 
SQL DDL
SQL DDLSQL DDL
SQL DDL
 
SQL for interview
SQL for interviewSQL for interview
SQL for interview
 
Sql ppt
Sql pptSql ppt
Sql ppt
 
Introduction to structured query language (sql)
Introduction to structured query language (sql)Introduction to structured query language (sql)
Introduction to structured query language (sql)
 
DML Commands
DML CommandsDML Commands
DML Commands
 
Joins in SQL
Joins in SQLJoins in SQL
Joins in SQL
 
Chapter 4 Structured Query Language
Chapter 4 Structured Query LanguageChapter 4 Structured Query Language
Chapter 4 Structured Query Language
 
SQL Joins.pptx
SQL Joins.pptxSQL Joins.pptx
SQL Joins.pptx
 
SQL Functions
SQL FunctionsSQL Functions
SQL Functions
 

Similar to SQL Queries - DDL Commands

Similar to SQL Queries - DDL Commands (20)

introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functions
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
 
unit-5 sql notes.docx
unit-5 sql notes.docxunit-5 sql notes.docx
unit-5 sql notes.docx
 
MySQL Essential Training
MySQL Essential TrainingMySQL Essential Training
MySQL Essential Training
 
SQL
SQLSQL
SQL
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
 
Oracle sql material
Oracle sql materialOracle sql material
Oracle sql material
 
SQL-SHORT-NOTES.pptx
SQL-SHORT-NOTES.pptxSQL-SHORT-NOTES.pptx
SQL-SHORT-NOTES.pptx
 
Sql
SqlSql
Sql
 
My sql.ppt
My sql.pptMy sql.ppt
My sql.ppt
 
Creating a database
Creating a databaseCreating a database
Creating a database
 
COMPUTERS SQL
COMPUTERS SQL COMPUTERS SQL
COMPUTERS SQL
 
Database models and DBMS languages
Database models and DBMS languagesDatabase models and DBMS languages
Database models and DBMS languages
 
MySQL Database System Hiep Dinh
MySQL Database System Hiep DinhMySQL Database System Hiep Dinh
MySQL Database System Hiep Dinh
 
mysqlHiep.ppt
mysqlHiep.pptmysqlHiep.ppt
mysqlHiep.ppt
 
mySQL and Relational Databases
mySQL and Relational DatabasesmySQL and Relational Databases
mySQL and Relational Databases
 
GFGC CHIKKABASUR ( DDL COMMANDS )
GFGC CHIKKABASUR ( DDL COMMANDS )GFGC CHIKKABASUR ( DDL COMMANDS )
GFGC CHIKKABASUR ( DDL COMMANDS )
 
My sql with querys
My sql with querysMy sql with querys
My sql with querys
 
Module 3
Module 3Module 3
Module 3
 

Recently uploaded

What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacingjaychoudhary37
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 

Recently uploaded (20)

What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacing
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 

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;