SlideShare a Scribd company logo
DDL Commands
•FIRST COMMANDS TO DEAL WITH DATABASE
•CREATE, ALTER, RENAME, DROP, TRUNCATE
ALTER TABLE Statement
• The ALTER TABLE statement is used to add, delete,
or modify columns in an existing table.
• The ALTER TABLE statement is also used to add
and drop various constraints on an existing table.
►To add a column in a table, use the
following syntax:
► ALTER TABLE table_name
ADD column_name datatype;
ALTERTABLE Statement
►To delete a column in a table, use
the following syntax :
►ALTER TABLE table_name
DROP COLUMN column_name;
ALTERTABLE Statement
ALTER TABLE Statement
►To change the data type of a
column in a table, use the following
syntax:
►ALTER TABLE table_name
MODIFY column_name datatype;
EXAMPLES :
►ALTER TABLE Persons
ADD DateOfBirth date;
►ALTER TABLE Persons
MODIFY name varchar2(30);
►ALTER TABLE Persons
DROP COLUMN DateOfBirth;
TRUNCATE COMMAND
►The Truncate SQL command is used to delete all
records from an existing oracle table.
►Removing rows with the TRUNCATE TABLE statement
can be faster than removing all rows with the
DELETE statement, especially if the table has
numerous triggers, indexes, and other
dependencies.
►Truncate drops the table first and then recreates
only the table structure which is much faster than
deleting the records one by one.
► Hence in case a table contains large number of
records, it works much faster than delete
statement.
TRUNCATE COMMAND
►Syntax :
TRUNCATE TABLE TABLE_NAME;
►Example:
1. TRUNCATE TABLE EMP;
2. TRUNCATE TABLE DEPARTMENT;
TRUNCATE COMMAND
DROP COMMAND
► The DROP command is used to remove an object from
the database.
► If u drop a table, all the rows in the table is deleted
and the table structure is removed from the database.
► Once a table is dropped we cannot get it back, so be
careful while using drop command.
► When a table is dropped all the references to the
table will not be valid.
► Syntax :
DROP TABLE TABLE_NAME;
► Example:
DROP TABLE EMP;
DROP TABLE DEPARTMENT;
DROP COMMAND
Difference
TRUNCATE DROP
Truncate command removes all
records from the specified table, but
keeps structure of the table intact.
Drop command removes all records
from the table along with the table
structure and puts it in recycle bin.
The records once deleted with
truncate command cannot be
recovered with the help of rollback.
The table removed with the drop
command can be recovered from the
recycle bin with the help of flashback
command.
Difference
TRUNCATE DELETE
Truncate command removes all
records from the specified table.
Delete command can delete one
or more records from the table.
The records once deleted with
truncate command cannot be
recovered with the help of
rollback.
The records once deleted with
delete command can be
recovered with the help of
rollback.

More Related Content

PPTX
DATABASE CONCEPTS AND PRACTICAL EXAMPLES
PDF
Sql delete, truncate, drop statements
PPTX
Introduction to database and sql fir beginers
PPT
Oracle naveen Sql
 
PPT
Oracle naveen Sql
 
PPTX
SQL : Structured Query Language
DOC
Oracle SQL AND PL/SQL
PPTX
GFGC CHIKKABASUR ( DDL COMMANDS )
DATABASE CONCEPTS AND PRACTICAL EXAMPLES
Sql delete, truncate, drop statements
Introduction to database and sql fir beginers
Oracle naveen Sql
 
Oracle naveen Sql
 
SQL : Structured Query Language
Oracle SQL AND PL/SQL
GFGC CHIKKABASUR ( DDL COMMANDS )

Similar to DDL Commands in Database Management System.pptx (20)

PPT
Les02
PPTX
SQL: Data Definition Language(DDL) command
PDF
DBMS.pdf
PPTX
8. sql
PPTX
MySQL Essential Training
DOCX
ii bcom dbms SQL Commands.docx
PPTX
SQL-SHORT-NOTES.pptx
DOC
SQL
PPTX
introdution to SQL and SQL functions
PPTX
Sql tables
PDF
SQL Queries - DDL Commands
PPTX
Structured Query Language(SQL)
DOCX
COMPUTERS SQL
 
PPTX
SQL Tutorial for Beginners
PPTX
Oraclesql
PPTX
Lesson 2_Working_with_Tables_and_SQL_Commands.pptx
PPTX
Oracle: DML
PPTX
Oracle : DML
PPTX
Commands of DML in SQL
PPT
Les10
Les02
SQL: Data Definition Language(DDL) command
DBMS.pdf
8. sql
MySQL Essential Training
ii bcom dbms SQL Commands.docx
SQL-SHORT-NOTES.pptx
SQL
introdution to SQL and SQL functions
Sql tables
SQL Queries - DDL Commands
Structured Query Language(SQL)
COMPUTERS SQL
 
SQL Tutorial for Beginners
Oraclesql
Lesson 2_Working_with_Tables_and_SQL_Commands.pptx
Oracle: DML
Oracle : DML
Commands of DML in SQL
Les10
Ad

Recently uploaded (20)

PPTX
oil_refinery_comprehensive_20250804084928 (1).pptx
PPT
ISS -ESG Data flows What is ESG and HowHow
PPTX
climate analysis of Dhaka ,Banglades.pptx
PPTX
STERILIZATION AND DISINFECTION-1.ppthhhbx
PPTX
AI Strategy room jwfjksfksfjsjsjsjsjfsjfsj
PPTX
Introduction-to-Cloud-ComputingFinal.pptx
PPTX
modul_python (1).pptx for professional and student
PPTX
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
PDF
[EN] Industrial Machine Downtime Prediction
PDF
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
PDF
Optimise Shopper Experiences with a Strong Data Estate.pdf
PPTX
Data_Analytics_and_PowerBI_Presentation.pptx
PPTX
Managing Community Partner Relationships
PDF
Business Analytics and business intelligence.pdf
PDF
.pdf is not working space design for the following data for the following dat...
PPTX
STUDY DESIGN details- Lt Col Maksud (21).pptx
PDF
Introduction to the R Programming Language
PPTX
01_intro xxxxxxxxxxfffffffffffaaaaaaaaaaafg
PPT
Predictive modeling basics in data cleaning process
oil_refinery_comprehensive_20250804084928 (1).pptx
ISS -ESG Data flows What is ESG and HowHow
climate analysis of Dhaka ,Banglades.pptx
STERILIZATION AND DISINFECTION-1.ppthhhbx
AI Strategy room jwfjksfksfjsjsjsjsjfsjfsj
Introduction-to-Cloud-ComputingFinal.pptx
modul_python (1).pptx for professional and student
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
[EN] Industrial Machine Downtime Prediction
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
Optimise Shopper Experiences with a Strong Data Estate.pdf
Data_Analytics_and_PowerBI_Presentation.pptx
Managing Community Partner Relationships
Business Analytics and business intelligence.pdf
.pdf is not working space design for the following data for the following dat...
STUDY DESIGN details- Lt Col Maksud (21).pptx
Introduction to the R Programming Language
01_intro xxxxxxxxxxfffffffffffaaaaaaaaaaafg
Predictive modeling basics in data cleaning process
Ad

DDL Commands in Database Management System.pptx

  • 1. DDL Commands •FIRST COMMANDS TO DEAL WITH DATABASE •CREATE, ALTER, RENAME, DROP, TRUNCATE
  • 2. ALTER TABLE Statement • The ALTER TABLE statement is used to add, delete, or modify columns in an existing table. • The ALTER TABLE statement is also used to add and drop various constraints on an existing table.
  • 3. ►To add a column in a table, use the following syntax: ► ALTER TABLE table_name ADD column_name datatype; ALTERTABLE Statement
  • 4. ►To delete a column in a table, use the following syntax : ►ALTER TABLE table_name DROP COLUMN column_name; ALTERTABLE Statement
  • 5. ALTER TABLE Statement ►To change the data type of a column in a table, use the following syntax: ►ALTER TABLE table_name MODIFY column_name datatype;
  • 6. EXAMPLES : ►ALTER TABLE Persons ADD DateOfBirth date; ►ALTER TABLE Persons MODIFY name varchar2(30); ►ALTER TABLE Persons DROP COLUMN DateOfBirth;
  • 7. TRUNCATE COMMAND ►The Truncate SQL command is used to delete all records from an existing oracle table. ►Removing rows with the TRUNCATE TABLE statement can be faster than removing all rows with the DELETE statement, especially if the table has numerous triggers, indexes, and other dependencies.
  • 8. ►Truncate drops the table first and then recreates only the table structure which is much faster than deleting the records one by one. ► Hence in case a table contains large number of records, it works much faster than delete statement. TRUNCATE COMMAND
  • 9. ►Syntax : TRUNCATE TABLE TABLE_NAME; ►Example: 1. TRUNCATE TABLE EMP; 2. TRUNCATE TABLE DEPARTMENT; TRUNCATE COMMAND
  • 10. DROP COMMAND ► The DROP command is used to remove an object from the database. ► If u drop a table, all the rows in the table is deleted and the table structure is removed from the database. ► Once a table is dropped we cannot get it back, so be careful while using drop command. ► When a table is dropped all the references to the table will not be valid.
  • 11. ► Syntax : DROP TABLE TABLE_NAME; ► Example: DROP TABLE EMP; DROP TABLE DEPARTMENT; DROP COMMAND
  • 12. Difference TRUNCATE DROP Truncate command removes all records from the specified table, but keeps structure of the table intact. Drop command removes all records from the table along with the table structure and puts it in recycle bin. The records once deleted with truncate command cannot be recovered with the help of rollback. The table removed with the drop command can be recovered from the recycle bin with the help of flashback command.
  • 13. Difference TRUNCATE DELETE Truncate command removes all records from the specified table. Delete command can delete one or more records from the table. The records once deleted with truncate command cannot be recovered with the help of rollback. The records once deleted with delete command can be recovered with the help of rollback.