SQL_TP[1]
SQL_TP[1]
Presentation
(SQL)
• Purpose:
DDL commands enable database administrators and developers to
create, modify, and delete database objects such as tables,
indexes, and constraints.
The CREATE TABLE statement is used to create a
new table in a database.
Syntax:
CREATE TABLE table_name (column1_name datatype, column2_name
datatype, column3_name datatype,....);
Syntax:
CREATE TABLE new_table_name AS SELECT column1, column2,... FROM
existing_table_name;
Example:
CREATE TABLE TestTable AS SELECT sid, sname, course FROM students;
SYNTEX: The syntax for SQL DROP Command is quiet similar to that of TRUNCATE
command except for the DROP keyword that is used in DROP command.
FOR EXAMPLES
Assume we have created a table named CUSTOMERS using the CREATE TABLE statement as shown below −
Customers table is ready in database , so let us now drop it with the help of ‘’DROP COMMAND’’.
Rename
InCommand:
My SQL, the RENAME Command is used to rename database objects such as
tables, columns, indexes, and views.
Syntax :
RENAME TABLE Current_table_name TO new_table_name;
For Example :
Rename table Employees TO Staff ;
Syntax :
2 Delete can also be used to delete all the rows from the table.
3 The difference is that delete performs a delete operation
on each row in the table and the database performs all
attendant tasks on the way.
Example:
TRUNCATE TABLE studios