Difference between delete and truncate statements

Difference between delete and truncate statements

There is a slight difference b/w delete and truncate statement. The DELETE statement only deletes the rows from the table based on the condition defined by WHERE clause or delete all the rows from the table when condition is not specified.
But it does not free the space containing by the sql table.
The TRUNCATE statement: it is used to delete all the rows from the sql table and free the containing space by the sql table.

The Example of DELETE a row from the sql table employee.

DELETE FROM employee WHERE emp_id=”10”; 

The Example of DELETE all row from the sql table employee.

DELETE FROM employee;

The Example of TRUNCATE the sql table employee.

TRUNCATE TABLE employee; 

Leave a Reply

Related Posts: You may like

comma separated values in mysql query

SQL statement to retrieve names beginning with A

Php pdo prepared statements select insert update queries

php pdo queries statements select insert update delete

PHPKIDA Offering Free Tools:

INSTA DOWNLOADER

Download Instagram Videos & Photos.

Download Now

CURRENCY CONVERTER

Real Time Currency Converter

Convert Now

ROBOST.TXT GEN.

Robots.txt File Creater

Create Now

HTML MINIFIER

Compress yout HTML Code

Minify Now

CSS MINIFIER

Compress yout CSS Code

Minify Now

JAVASCRIPT MINIFIER

Compress yout JavaScript Code

Minify Now

Sign up for weekly update

Milkshake is almost ready. If you're interested in testing it out, then sign up below to get exclusive access.