In this tutorial i will discuss about SQL Drop truncate and Alter statement,their purpose , syntax and suitable example.I hope this must helpful for you.
Purpose of SQL ALTER:
ALTER TABLE statement is used to add, delete, or modify columns in an existing table.
Syntax Of SQL ALTER TABLE:
To add a column in a table, we will use the following
ALTER TABLE `teacher info2` ADD COLUMN MobileNo INT
ALTER TABLE table_name DROP COLUMN column_name
ALTER TABLE `teacher info2` DROP COLUMN MobileNo
If you want to run the above query then fist click on view code then copy & past otherwise you get an extra space sign like
After executing the above code we can see the following massage:
If you press Ok button then you will see following output.
If we want t o change the data type of a column in a table,
we will use the following
For SQL Server / MS Access
DROP TABLE Statement:
Purpose of DROP TABLE Statement:
The DROP TABLE statement is used to delete a table.
Syntax Drop Table statement:
DROP TABLE tbl_name
DROP DATABASE Statement:
Purpose of DROP DATABASE Statement:
DROP DATABASE statement is used to delete a database.
TRUNCATE TABLE Statement:
When we use TRUNCATE TABLE Statement:
If we only want to delete the data inside the table faster but not the table itself.
Then we will use the TRUNCATE TABLE statement: