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

PPTX
SQL - DML and DDL Commands
PPT
Introduction to structured query language (sql)
PPTX
Sql joins inner join self join outer joins
PPTX
The Relational Database Model
PPTX
Super keyword in java
PPT
Sql Tutorials
PPTX
Nested queries in database
PPT
SQL - DML and DDL Commands
Introduction to structured query language (sql)
Sql joins inner join self join outer joins
The Relational Database Model
Super keyword in java
Sql Tutorials
Nested queries in database

What's hot (20)

PPTX
PDF
PPTX
SQL Functions
PPT
Constraints In Sql
PPTX
basic structure of SQL FINAL.pptx
PPT
Joins in SQL
PDF
SQL Overview
PPT
Sql DML
PPT
Mysql
PPTX
DATABASE CONSTRAINTS
PPTX
Acid properties
PPTX
SQL Data types and Constarints.pptx
PPT
Relational algebra operations
PPT
SQL subquery
PPTX
SQL Commands
PPTX
set operators.pptx
PPTX
Joins And Its Types
PPT
Sql basics and DDL statements
PPT
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
SQL Functions
Constraints In Sql
basic structure of SQL FINAL.pptx
Joins in SQL
SQL Overview
Sql DML
Mysql
DATABASE CONSTRAINTS
Acid properties
SQL Data types and Constarints.pptx
Relational algebra operations
SQL subquery
SQL Commands
set operators.pptx
Joins And Its Types
Sql basics and DDL statements
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Ad

Similar to SQL Queries - DDL Commands (20)

PPTX
introdution to SQL and SQL functions
PPTX
Lecture - MY-SQL/ SQL Commands - DDL.pptx
DOCX
unit-5 sql notes.docx
DOCX
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
PPTX
SQL commands in database managemant systems
PPTX
SQL(DDL & DML)
PPTX
Introduction to SQl Commands.pptxhhjhvvb
DOCX
SQL Tutorial for BCA-2
PPTX
SQL: Data Definition Language(DDL) command
PPTX
Database Languages power point presentation
PPTX
GFGC CHIKKABASUR ( DDL COMMANDS )
PPTX
data manipulation language
PPTX
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
PPTX
SQL commands powerpoint presentation. Ppt
PPTX
Unit - II.pptx
PPTX
DBMS UNIT-2.pptx ggggggggggggggggggggggg
PPT
chapter 8 SQL.ppt
PPTX
Fundamentals of Database management system Lab Manual.pptx
PPTX
SQl data base management and design
PDF
Dms 22319 micro project
introdution to SQL and SQL functions
Lecture - MY-SQL/ SQL Commands - DDL.pptx
unit-5 sql notes.docx
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
SQL commands in database managemant systems
SQL(DDL & DML)
Introduction to SQl Commands.pptxhhjhvvb
SQL Tutorial for BCA-2
SQL: Data Definition Language(DDL) command
Database Languages power point presentation
GFGC CHIKKABASUR ( DDL COMMANDS )
data manipulation language
hjkjlboiupoiuuouoiuoiuoiuoiuoiuoippt.pptx
SQL commands powerpoint presentation. Ppt
Unit - II.pptx
DBMS UNIT-2.pptx ggggggggggggggggggggggg
chapter 8 SQL.ppt
Fundamentals of Database management system Lab Manual.pptx
SQl data base management and design
Dms 22319 micro project
Ad

Recently uploaded (20)

PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PPTX
OOP with Java - Java Introduction (Basics)
PPTX
additive manufacturing of ss316l using mig welding
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
Geodesy 1.pptx...............................................
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PPTX
Artificial Intelligence
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPT
Project quality management in manufacturing
PPTX
web development for engineering and engineering
PPT
Mechanical Engineering MATERIALS Selection
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
composite construction of structures.pdf
PPTX
Safety Seminar civil to be ensured for safe working.
PDF
Digital Logic Computer Design lecture notes
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
OOP with Java - Java Introduction (Basics)
additive manufacturing of ss316l using mig welding
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Automation-in-Manufacturing-Chapter-Introduction.pdf
Internet of Things (IOT) - A guide to understanding
bas. eng. economics group 4 presentation 1.pptx
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Geodesy 1.pptx...............................................
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
Artificial Intelligence
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
Project quality management in manufacturing
web development for engineering and engineering
Mechanical Engineering MATERIALS Selection
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
composite construction of structures.pdf
Safety Seminar civil to be ensured for safe working.
Digital Logic Computer Design lecture notes

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;