SQL Drop Table:
The SQL DROP TABLE statement is used to delete a table definition and all data, indexes, triggers, constraints, and permission specifications for that table.
NOTE: Once a table is deleted then all the information in the table would be lost forever. Please be careful while using this statement. .
DROP TABLE table_name;
Before executing the DROP table, we first check whether the required table is available in the Database or not.
SELECT * FROM SCOREBOARD;
Now let’s execute SQL Drop Table statement to drop the table.
DROP TABLE SCOREBOARD;
Execute the above mentioned SELECT query again and check it out. An error message will display as mentioned below.
Msg 208, Level 16, State 1, Line 1 Invalid object name 'SCOREBOARD'.
Check the below mentioned image.
SQL Drop Database:
Let’s see how to delete a database completely.
The DROP DATABASE statement is used to delete a database
DROP DATABASE database_name;
Let’s see how to truncate data from a table:
if we only want to delete the data inside the table, and not the table itself?
Then, use the TRUNCATE TABLE statement:
TRUNCATE TABLE table_name;
In the next tutorial, we will learn JOINS in SQL
Check out the complete SQL Tutorial by clicking on below link: