Search code examples
db2case-sensitivedatabase-administrationdb2-luw

Drop table that has the name in lower case from the command line


I need to delete a table that has a lower case name, i.e. academy

However when I do db2 drop table academy or db2 drop table "academy" I get:

DB21034E  The command was processed as an SQL statement because it was not a 
valid Command Line Processor command.  During SQL processing it returned:
SQL0204N  "DB2INST1.ACADEMY" is an undefined name.  SQLSTATE=42704

The same command worked for upper case table names though.

When I list my tables I have > db2 LIST TABLES

Table/View                      Schema          Type  Creation time             
------------------------------- --------------- ----- --------------------------
AA                              DB2INST1        T     2016-06-07-14.23.08.927146
MYNEWTABLE                      DB2INST1        T     2016-06-07-14.29.50.859806
academy                         DB2INST1        T     2016-06-07-17.05.27.510905

Solution

  • In db2 drop table "academy" quotes get swallowed by the shell. You'll need to escape them:

    db2 drop table \"academy\" 
    

    or quote the entire statement:

    db2 'drop table "academy"'