Forum OpenACS Q&A: How to flush MySql database table?????

I have a database with 10 different tables in it. Each table has huge amount of data stored in them. I want to clear all that data but do not want to effect any of the fields of the tables. I just want all stored data should be cleared. How can I do that.. anyone have any idea... pls help.. it is urgent...

JD

Collapse
Posted by Rob Storrs on
To drop data without changing the table structure:
delete from [tablename]; (replace [tablename] with the name of your table)

That will delete all rows in the table without modifying the table structure. All of the data will be removed from the table. This is a pretty basic SQL function, you may want to review a SQL reference (like SQL for Web Nerds).

Collapse
Posted by Tom Jackson on

In pg or Oracle, you can do: 'truncate tablename'. It is much faster than 'delete from tablename'.

Collapse
Posted by Jonathan Ellis on
truncate also works in Sybase and probably by extension MS SQL.