TRUNCATE TABLE & DROP TABLE Commands in SQL || Lesson 43 || DBMS || Learning Monkey ||

Опубликовано: 02 Октябрь 2024
на канале: Learning Monkey
1,430
24

TRUNCATE TABLE and DROP TABLE Commands in SQL

In this class, we will understand TRUNCATE TABLE and DROP TABLE Commands in SQL.

We have already discussed the concepts of alter table.

TRUNCATE TABLE and DROP TABLE Commands in SQL

To understand, we will use the user’s table as shown below.

In the above table, we have two rows.
TRUNCATE TABLE Command

The TRUNCATE TABLE statement deletes the data inside a table, but not the table itself.

If we want to delete all the rows in the table, we have to use the truncate command.

With the truncate, we can delete all the rows in the table, but not the table itself.

The syntax for truncate is as shown below.

TRUNCATE TABLE table_name;

Now, we will truncate the user’s table.

TRUNCATE TABLE users;

We will check whether the rows have been deleted or not by using the select command.


The table has been truncated.
DROP TABLE Command

The DROP TABLE statement is used to drop an existing table in a database.

To delete the structure of the table, we use the drop command.

The syntax to drop a table is as shown below.

DROP TABLE table_name;

DROP TABLE users;

The user’s table no more exists.

Let us check with the select command.



#learningmonkey #dbms #placements #gatecse #gatedbms #campusplacements




Link for playlists:
   / @learningmonkey  


Link for our website: https://learningmonkey.in

Follow us on Facebook @   / learningmonkey  

Follow us on Instagram @   / learningmonkey1  

Follow us on Twitter @   / _learningmonkey  

Mail us @ [email protected]