Two Laptop Bag
The moose likes JDBC and the fly likes Java DB - Delete all records in a table. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Java DB - Delete all records in a table." Watch "Java DB - Delete all records in a table." New topic
Author

Java DB - Delete all records in a table.

ash neet
Ranch Hand

Joined: Dec 21, 2010
Posts: 33
Hey,
Can anyone please tell me how do i delete all the records in a table with a single query?
I am using Squirrel SQL client for databases.
I tried using -> truncate table table_name;
but it is'nt working.

Thanks in advance!
Swastik Dey
Ranch Hand

Joined: Jan 08, 2009
Posts: 1195

How about using delete from tablename?


Swastik
ash neet
Ranch Hand

Joined: Dec 21, 2010
Posts: 33
Swastik Dey wrote:How about using delete from tablename?


Hey Thanks Swastik, it worked!
but i want to restore the auto-increment primary key after deleting all records, that's why i was using truncate. how do we do this in java DB?
Swastik Dey
Ranch Hand

Joined: Jan 08, 2009
Posts: 1195

Whats going wrong with truncate?
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2343

ash neet wrote:...I tried using -> truncate table table_name;
but it is'nt working.
...
What happens?


OCUP UML fundamental
ITIL foundation
ash neet
Ranch Hand

Joined: Dec 21, 2010
Posts: 33
Jan Cumps wrote:
ash neet wrote:...I tried using -> truncate table table_name;
but it is'nt working.
...
What happens?


it gives me the following error when i use the syntax - "truncate table table_name"
Error: Feature not implemented: truncate table.
Swastik Dey
Ranch Hand

Joined: Jan 08, 2009
Posts: 1195

This seems to be a bug in java db
http://www.talendforge.org/forum/viewtopic.php?id=784
ash neet
Ranch Hand

Joined: Dec 21, 2010
Posts: 33
Swastik Dey wrote:This seems to be a bug in java db
http://www.talendforge.org/forum/viewtopic.php?id=784


Thanks! i will upgrade my java db.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Java DB - Delete all records in a table.
 
Similar Threads
How to delete a record from a table without a primary key
Insert new records in database without deleting existing records
Delete operation as small chunks on records?
how to delete huge amount of records
optimization of database