SQL DDL Commands - Data Definition Language

SQL DDL Commands - Data Definition Language


TUTORIAL IN HINDI


Download

DDL changes the structure of the table like creating a table, deleting a table, altering a table, etc.

All the command of DDL are auto-committed that means it permanently save all the changes in the database.


CREATE – It is used to create a new table in the database.


SYNTAX:

CREATE TABLE Table_Name (Column_Name DataType , ..........);


EXAMPLE:

CREATE TABLE STUDENT(Name VARCHAR2(20), Email VARCHAR2(100), DOB DATE);



-------------------------------------------------------------------------------------------


DROP – It is used to delete both the structure and record stored in the table.

               We can drop database and table.

SYNTAX:

DROP TABLE Table_Name;

DROP DATABASE Database_Name;


EXAMPLE:

DROP TABLE STUDENT;

DROP DATBASE MASTER;


---------------------------------------------------------------------------------------------


ALTER – It is used to alter the structure of the database. This change could be either to modify the characteristics of an existing attribute or probably to add a new attribute.

SYNTAX:

ALTER TABLE Table_Name ADD Column_Name Column-Definition;    

ALTER TABLE Table_Name MODIFY(Column_Definitions); 



EXAMPLE:

ALTER TABLE STUDENT ADD(ADDRESS VARCHAR2(20));  
ALTER TABLE STUDENT MODIFY (NAME VARCHAR2(20));


------------------------------------------------------------------------------------------


TRUNCATE: It is used to delete all the rows from the table and free the space containing the table.


SYNTAX:

TRUNCATE TABLE Table_Name;



EXAMPLE:  

TRUNCATE TABLE STUDENT;



---------------------------------------------------------------------------------------------


Follow Us :-

YouTube:

Post a Comment

0 Comments