Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

deleting all the records in a table

Status
Not open for further replies.

Octagon6

Programmer
Mar 18, 2003
18
US
what is the easiest way to delete all the records in a table? I'm thinking of just writing a sql statement in the command window. What would it look like?

delete * from [tablename]????
 
Hi

DELETE ALL

:) ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com

 

Of course, there is the unforgiving (if SET SAFETY is OFF) ZAP command.

Al
 
ramani...
that didn't work.. the records are still there. don't you have to specify the table name you are deleting the records from? also, is their a better way to do this?
 
Octagon6

SET DELETED ON
DELETE ALL
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Wahoo! Thanks mike... I was wondering why that wasn't working.
 
You can also use:

DELETE FROM tablename
or
DELETE FROM tablename WHERE logicalExpression
 
To actually make the records "go away" permanently afer a DELETE command, you'd have to PACK the table. Otherwise the DELETE command just marks the records as deleted and toggling SET DELETED ON/OFF either shows or doesn't show the marked for deletion records.

DELETED but not PACKED records can be "brought back" with RECALL.

ZAP is the fastest was to remove all records.

To get an empty table with the same stucture, you can use COPY STRUCTURE TO NewTable

Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top