Search
 
SCRIPT & CODE EXAMPLE
 

SQL

delete vs truncate sql server

DELETE:
1.Delete command is used to delete a row in a table.
2.You can rollback data after using delete statement.
3.It is a DML command.
4.It is slower than truncate statement.

-- DELETE Syntax 
DELETE FROM table_name WHERE condition;

TRUNCATE:
1.Truncate is used to delete all the rows from a table
2.You cannot rollback data.
3.It is a DDL command.
4.It is faster.

-- TRUNCATE Syntax 
TRUNCATE TABLE table_name;
Comment

truncate delete and drop in sql

DELETE -
-DML COMMAND
-Delete Rows from the table one by one
-We can use where clause with Delete to delete single row
-Delete is slower than truncate
-ROLLBACK is possible with DELETE

DROP-
-DDL COMMAND
-Delete the entire structure or schema
-We can't use where clause with drop
-Drop is slower than DELETE & TRUNCATE
-ROLLBACK IS NOT POSSIBLE WITH DROP

TRUNCATE-
-DDL COMMAND
-Truncate deletes rows at a one goal
-We can't use where clause with Truncate
-Truncate faster than both DELETE & DROP
-Rollback is not possible with Truncate
Comment

SQL Delete and Truncate Rows

DELETE FROM Customers
WHERE customer_id = 5;
Comment

PREVIOUS NEXT
Code Example
Sql :: mysql create database 
Sql :: sql query interview questions 
Sql :: sql server in python 
Sql :: how to join result table in mysql 
Sql :: SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client . Can not run php artisan migrate 
Sql :: insert into 
Sql :: how to uninstall mysql windows 10 
Sql :: Oracle Procedure ex2 
Sql :: casterar postgres 
Sql :: setup mysql and wordpress on docker mac 
Sql :: mysql case sensitive ? 
Sql :: grant privileges mysql to database 1064 
Sql :: realtime database push multiple values 
Sql :: First Step in installing SQL workbench 
Sql :: Column count of mysql.user is wrong. Expected 42, found 44. The table is probably corrupted 
Sql :: convert linq to sql query online 
Sql :: leftjoin in sql 
Sql :: get start of week big query 
Sql :: delete recurring email keep smallest id number 
Sql :: concatenate sqlites 3 
Sql :: how to use multiple transactions in sql server 
Sql :: How to calculate average of average salary of departments? 
Sql :: mysql where in maintain order 
Sql :: sütun güncelleme SQL 
Sql :: order records between two cordinates sql 
Sql :: what is constraints in dbms 
Sql :: como hacer una consulta en sql 
Sql :: get last 3 years data in mysql 
Sql :: ring MySQL get the inserted row id 
Sql :: transaction in java mysql 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =