Delete all tables in Derby DB

后端 未结 10 941
离开以前
离开以前 2020-12-30 05:42

How do i delete all the tables in the schema on Apache Derby DB using JDBC?

相关标签:
10条回答
  • 2020-12-30 06:21

    If you're working from the command prompt rather than through JDBC, this should get you started.

    SELECT 'DROP TABLE ' || schemaname ||'.' || tablename || ';'
    FROM SYS.SYSTABLES
    INNER JOIN SYS.SYSSCHEMAS ON SYS.SYSTABLES.SCHEMAID = SYS.SYSSCHEMAS.SCHEMAID
    ;
    
    0 讨论(0)
  • 2020-12-30 06:23

    I think most db providers don't allow DROP TABLE * (or similar).

    I think the best way would be to SHOW TABLES and then go through each deleting in a loop via a resultset.

    HTH.

    0 讨论(0)
  • 2020-12-30 06:23

    Download Squirrel SQL from http://squirrel-sql.sourceforge.net/

    Connect to the database.

    Expand the TABLE node.

    Select the tables that you want to drop.

    Right click and select -> Scripts -> Drop table scripts

    Run the generated queries

    You can even select delete records to empty the selected tables.

    0 讨论(0)
  • 2020-12-30 06:25

    Do a little method in java in which you execute a

    DROP TABLE [tablename]
    

    tablename is passed by parameter.

    And another method in which you loop over a record set formed by the query

    SELECT tablename FROM SYSTABLES
    

    calling the first method.

    Derby latest documentation

    0 讨论(0)
提交回复
热议问题