0% found this document useful (0 votes)
22 views10 pages

2.5 DDL Commands

Uploaded by

omeshshewale965
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views10 pages

2.5 DDL Commands

Uploaded by

omeshshewale965
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Database Management System

By
Mr. Parag R. Sali
Lecturer
Department of Computer Technology
SNJB’s Shri. Hiralal Hastimal ( Jain Brothers)
Polytechnic, Chandwad
Program Name: Computer Engineering Group
Program Code : CO/CM/CW
Semester : Third
Course Title : Database Management System
Course Code : 22319

DDL Commands
COMPONENTS OF SQL
DDL, DML, DCL, TCL,DQL
 Database languages are categorized as follows

DDL

Components of SQL
DML

DCL

TCL

DQL
DATA DEFINITION LANGUAGE (DDL)
 Data definition language is used to define data and their
relationship to other type of data
 It is used to create tables, dictionaries and files in database
 Statements/ commands comes under DDL language are :
 Create: used to create database instance
 Alter : used to alter the structure of database
 Drop: used to drop database instances
 Rename : used to rename database instances
 Truncate : used to truncate the database instances
 Desc : used to display the structure of object
In DBMS data is storing in tables
Tables also known as relations
It is combination of rows and columns
 Create Command :
 The CREATE TABLE statement is used to create table in
database.
 In the CREATE TABLE statement column parameters
specify the name of field of the table
 The data type is type of data which we want to store in the
respective fields
 The fields can hold data of different types like char, int,
varchar, number etc.
 The optional size value can be mentioned after the data type.
 Syntax :
 Create table table_name (column1 datatype [size], column2 datatype
[size],
column3 datatype [size],
……
column n, datatype [size]);
 Example :
 Create table student (name varchar(20),
roll_no integer, marks integer);

Student Table:

name roll_no marks


 Alter command :
 Alter command is used to modify structure of table,
 We can add, delete or modify column

 Syntax :
• Alter table table_name add cloumn_name datatype;
• Alter table table_name drop column cloumn_name;
• Alter table table_name modify column cloumn_name datatype;
• Alter table table_name rename to new_table_name;

 Example :
• Alter table student add city varchar(25);
• Alter table student drop column city ;
• Alter table student modify column name varchar (30) ;
 Drop command :
 Drop table query is used to clear table permanently from the
database.
 Syntax :
• Drop table table_name;
 Example :
• Drop table student;
 Rename command :
 Rename table query is used to rename table in the database.
 Alter command is also used to rename table name
 Syntax :
• Alter table table_name rename to new_table_name;
• Rename table old_table_name to new_table_name;
 Example :
• Alter table student rename to student1;
• Rename table student to student1;
 Truncate command :
 Truncate table command is used to delete all records from
table
 Syntax :
• Truncate table table_name;
 Example :
• Truncate table student;

 Desc (Describe) command :


 Desc query is used to display the structure of table
 Syntax :
• Desc table_name;
 Example :
• Desc student;

You might also like