Posted by: tonyteaching | March 23, 2009

to DELETE All DATA or just Specific Data in a Table

1. DELETE ALL DATA

There are 2 ways to delete all the data in a MySQL database table:

TRUNCATE TABLE tablename;

This will delete all data in the table very quickly. In MySQL the table is actually dropped and recreated, hence the speed of the query. The number of deleted rows for MyISAM tables returned is zero; for INNODB it returns the actual number deleted.

DELETE FROM tablename;

This also deletes all the data in the table, but is not as quick as using the “TRUNCATE TABLE” method. In MySQL >= 4.0 the number of rows deleted is returned; in MySQL 3.23 the number returned is always zero.

—————————

2. DELETE Specific Data

for example we want to delete data/row with employee id=10 from Table “employee_data”:

DELETE FROM employee_data WHERE emp_id=10;



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: