Search
 
SCRIPT & CODE EXAMPLE
 

SQL

ms sql truncate table vs delete

-- Quick, no possible rollback
TRUNCATE TABLE my_table;
-- With possible rollback
DELETE FROM my_table;
COMMIT;  -- or ROLLBACK;
Comment

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

PREVIOUS NEXT
Code Example
Sql :: mysql connection string 
Sql :: how to create an empty table from an existing table 
Sql :: how to know password of mysql root in linux terminal 
Sql :: select tables from mysql database 
Sql :: sql server date now 
Sql :: oracle asynchronous query 
Sql :: alter table auto_increment 
Sql :: wsl centos 8 mysql 
Sql :: insert multiple rows in sql workbench 
Sql :: best sql course 
Sql :: this week mysql 
Sql :: mysql last year 
Sql :: real world example of nosql 
Sql :: date in where on datetime column clause mysql 
Sql :: check isolation level in mysql 
Sql :: how to alter table column name in mysql 
Sql :: get row affected mysql 
Sql :: delete a record from a table sqlite3 
Sql :: how to remove a column from a table in MySQL 
Sql :: datepart postgres 
Sql :: oracle pl sql source 
Sql :: can you update NULL in sql 
Sql :: sql server substring 
Sql :: db.Database.SqlQuery 
Sql :: drop index oracle 
Sql :: mysql change auto_increment start value 
Sql :: oracle sql date get month 
Sql :: create user sql server 
Sql :: mysql database is not starting in xampp 
Sql :: min salary in sql 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =