Statements in SQL
There are five type of statements in SQL.
- Data Definition Language (DDL).
- Data Manipulation Language (DML).
- Data Control Language (DCL).
- Transaction Control Language (TCL).
- Data Query Language(DQL).
1.Data Definition Language - Create , Alter , Rename , Turncate , Drop.2.Data Manipulation Language - Insert , Delete , Update.3.Data Control Language - Grant , Revoke.4.Trancation Control Language - Commit , Savepoint , Rollback.5. Data Query Language - Select , Projection , Selection , Joins.
1.DDL (Data Definition Language) -
Create - Create command is use to create the table.
Alter - Alter is use to perform the modification in the table.
Rename - Rename is use to change the name of table.
Syntax - rename old_tablename to new_tablename;
Example - rename emp to employee;
Truncate - It is use to delete all the data of the table without affecting the table structure. If a table is truncated the data which is deleted can not be recovered.
Syntax - truncate table table_name;
Example - truncate table salgrade;
Drop -Drop is use to delete table along withs all its data
If table is drop is goes to recycle bin and it can be recover or restored.
Syntax - Drop table table_name;
Example - Drop table salgrade;
How to recover table with same name .1.Table should be drop. Drop table
2.Flashback table table_name To befor drop;
Example - flashback table salgrade
to befor drop;
How to recover table with different name.1.Table should be drop drop table
2.flashback table table_name To befor drop
Rename to new_name;
How to delete table permanantly1. Table should be drop.2.When table is present in recycle bin we need to execute following command.Syntax - purge table table_name;Example - purge table salgrade;
If a table is truncated the data which is deleted can not be recovered.Syntax - truncate table table_name;
If table is drop is goes to recycle bin and it can be recover or restored.
Syntax - Drop table table_name;
Example - Drop table salgrade;
0 Comments