SQL Table Operations:
Table is a collection of data organized in term of rows and columns or you can say table has row and column which contain the data.
Below are the list of operations which can be perform on SQL database.
- CREATE Table
- DROP Table
- DELETE Table
- RENAME Table
- TRUNCATE Table
- COPY Table
- TEMP Table
- ALTER Table
CREATE TABLE Tablename
(
ColumnName1 datatypes constraint (Optional),
ColumnName2 datatypes,
ColumnName3 datatypes,
etc..)
2-DROP Table :
DROP Table Statement is used to delete the table definition and all data present in table.
Syntax:
DROP TABLE TableName;
3) DELETE Table :
The Delete Statement is used to delete the records from Table. if you want to remove specific row from a table you should use Where clause.
Syntax:-
DELETE FROM TableName where [condition]
Please note if you did not put the where condition then it will delete all records present in table.
4) RENAME Table :
If users want to change the name of the table in the SQL database because they want to give a more relevant name to the table
Syntax :RENAME old_table _name To new_table_name;
5) Truncate Table :
A truncate SQL statement is used to remove all rows (complete data) from a table. It is similar to the DELETE statement with no WHERE clause.
Syntax : Truncate Table Tablename;
6) COPY Table :
- If you want to copy the data of one SQL table into another SQL table in the same SQL server, then it is possible by using the SELECT INTO statement in SQL.
- The SELECT INTO statement in Structured Query Language copies the content from one existing table into the new table. SQL creates the new table by using the structure of the existing table
Syntax: SELECT * INTO New_table_name FROM old_table_name
7) Temp Table : details to be added soon
8) Alter Table :
The ALTER TABLE statement in Structured Query Language allows you to add, modify, and delete columns of an existing table.
Syntax :
ALTER TABLE table_name ADD column_name datatype