Hi friends Today i am going to explain,what is Delete and Truncate statement in Sql Server . Sql is the main element of any Database.If you want to understand full concepts (step by step) of Ms Sql Server then here .If you want o learn somethings in your life then patience is more necessary.If you understand all concept of Ms Sql Server then ado.net will very easy for you.
Delete and Truncate statement can be used to remove the data from the table.
Delete Sql command:
Syntax:
delete from Table Name where Clause.
Ex: delete from employee where sid=101;
Truncate Sql command:
Syntax:
truncate table Table Name;
Ex:
truncate table employee;
There are some differences between delete and truncate statement which is given below:
Drop command removes a table from the database.when one time delete then we can not recover it.
Syntax:
drop table Table Name;
Ex:
drop table employee;
For More:-
I hope this is helpful for you.
To Get the Latest Free Updates SubscribeDelete and Truncate statement can be used to remove the data from the table.
Delete Sql command:
Syntax:
delete from Table Name where Clause.
Ex: delete from employee where sid=101;
Truncate Sql command:
Syntax:
truncate table Table Name;
Ex:
truncate table employee;
There are some differences between delete and truncate statement which is given below:
- In case of delete each row is deleted one by one and deleted entry is made within log file but In case of truncate table structure is drop and recreated rows are not deleted physically.
- Truncate is faster than delete.
- Within delete statement we can specify 'Where' clause but in truncate statement we can not specify the 'Where' clauses.
- In case of Identity column the difference is,if we run delete statement then insert a new record then identity column value will be the next value of the last inserted values.But if we run truncate statement and insert a new record the next value seed value.
- In case of Foreign key constraint the difference is, if child table does not have any record then we can run delete statement against parents table but we can not run truncate statement against parent table.
- Delete is DML Statement and truncate is DDL Statement.
- If record is deleted that can be recover but if record is truncated then can not recover.
Drop command removes a table from the database.when one time delete then we can not recover it.
Syntax:
drop table Table Name;
Ex:
drop table employee;
For More:-
- Default Constraints in SQL
- Check Constraints is SQL
- Copy Data from one table to another table
- Create Dataset and Data Adapter
- Exception Handling
I hope this is helpful for you.
I ωant to to thanκ you for this great rеad!
ReplyDelete! I certainlу loveԁ еvery bіt of
it. I've got you bookmarked to check out new stuff you post…
Look into my site: H�moriden