DDL: Data Definition Language
Truncate is a simple DDL command in SQL Server.
Truncate command in SQL Server works very similar to DELETE command.
Since TRUNCATE command will not store the logs, truncated data from a table cannot be restored back.
Here is the syntax for TRUNCATE Command:
Syntax:
TRUNCATE TABLE <Table Name>
Example:
Lets see how we can truncate data from a table with the name MOBILE:
Data in the table before running Truncate command:
Run the following command in SQL SERVER Query Window:
TRUNCATE TABLE MOBILE
Data in the table After running Truncate command:
Few important points about TRUNCATE Command in SQL Server
Summary:
Here we have learnt about TRUNCATE Command.
Truncate is a simple DDL command in SQL Server.
Truncate command in SQL Server works very similar to DELETE command.
Since TRUNCATE command will not store the logs, truncated data from a table cannot be restored back.
Here is the syntax for TRUNCATE Command:
Syntax:
TRUNCATE TABLE <Table Name>
Example:
Lets see how we can truncate data from a table with the name MOBILE:
Data in the table before running Truncate command:
Run the following command in SQL SERVER Query Window:
TRUNCATE TABLE MOBILE
Data in the table After running Truncate command:
Few important points about TRUNCATE Command in SQL Server
- Since TRUNCATE Command operates(manipulates) on data in the table ,many people assume it as a DML statement. But, TRUNCATE is a DDL Command.
- TRUNCATE Command will not operate on each row (or each data). It will operate on the entire database object. So, it will consume fewer database resources than DELETE Command
- TRUNCATE command will not store logs
- Data Truncated once cannot be restored back.
Summary:
Here we have learnt about TRUNCATE Command.
Thanks for sharing valuable information and keep posting. Keep sharing.
ReplyDeleteetl testing course in hyderabad
etl testing online course