Thursday, August 9, 2012

Difference in Delete and Truncate in MySQL

hmm wondering what the difference is.... in Oracle
DELETE should follow COMMIT

TRUNCATE sorry no return bye bye command..

in MySQL...

lets take an table called
users
{
   id (INT: Primary Key | AUTO INCREMENT),
   name : VARCHAR(20)
}


id     name
1      Tania
2      Jane
3      Andrea

DELETE FROM users -----> deletes all records

so does

TRUNCATE TABLE users ----> but id is set to 1 again...

No comments:

Post a Comment

About

Blogger templates