How to Truncate Table in SQL

preview_player
Показать описание
Follow this easy step by step tutorial to learn how to use Truncate Table query in SQL and see how data can be removed from the table.

Truncate Table command allows us to delete all the data in the table without deleting the table itself. This command does not delete the entire table, but it only deletes the records inside the table.
In this tutorial we will learn to truncate a table in SQL.

Step 1- Viewing Table Data
First of all let us view the records from any table, let it be dummy in our case.
For that write:
Select * from dummy
and execute it by pressing F5.

Step 2- Executing Command
Now write the Truncate Table command along with the required table name.
The query would be:
Truncate table dummy
and execute it .

Step 3- Data Removed
Now view the records of dummy table again, you will observe that the table would be empty with no records present.
That is what the Truncate Table query does.

And that is how we can truncate a table in SQL.
Рекомендации по теме
Комментарии
Автор

I like this kind of tutorial, I hate the other tutorials who is so explanatory.

endone
Автор

Nice video. Right to the point. Could also mention that there is no pull-down or menu option for truncate in SSMS, oddly. Must resort to T-Sql, as this video demonstrates.

peternmi