aspose file tools*
The moose likes JDBC and the fly likes Java DB - Delete all records in a table. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
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
Rancher

Joined: Jan 08, 2009
Posts: 1479
    
    6

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
Rancher

Joined: Jan 08, 2009
Posts: 1479
    
    6

Whats going wrong with truncate?
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2516
    
  10

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


OCUP UML fundamental and ITIL foundation
youtube channel
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
Rancher

Joined: Jan 08, 2009
Posts: 1479
    
    6

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://aspose.com/file-tools
 
subject: Java DB - Delete all records in a table.