Home » SQL & PL/SQL » SQL & PL/SQL » how to delete all record in the table?
icon5.gif  how to delete all record in the table? [message #247121] Sun, 24 June 2007 06:46 Go to next message
matrik02
Messages: 64
Registered: November 2005
Member
I would like to know, what command to delete all record in the table?

I am little confuse between command to delete the table and command to delete the record in the table..
Re: how to delete all record in the table? [message #247122 is a reply to message #247121] Sun, 24 June 2007 07:16 Go to previous message
michael_bialik
Messages: 611
Registered: July 2006
Senior Member
1. Just to delete the data ( rows );

DELETE FROM <table_name>;
COMMIT;


2. If no foreign key exists referencing the table and you don't have triggers attached to it - you can use also:

TRUNCATE TABLE <table_name>;


Truncate is DDL command, so it's already has an implied commit.

Both above mentioned commands delete the data, but table definition remains intact.

3. To "delete" table (incuding table definitions) you can use:
DROP TABLE <table_name>;


It's also DDL, so no commit is necessary.

HTH.
Michael


Previous Topic: Problem in designing a database for project management
Next Topic: problem with 'not a single group function'
Goto Forum:
  


Current Time: Thu Dec 08 04:01:08 CST 2016

Total time taken to generate the page: 0.10468 seconds