我试图通过命令行在 DB2 中删除一个外键。我已经成功了很多次,我确信我使用了正确的语法:
db2 "alter table TABLENAME drop constraint fk_keyname"
输出:
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 "FK_KEYNAME" is an undefined name. SQLSTATE=42704
我所有的外键都是用大写的名字创建的。除了我现在想放下的钥匙。我不知道如何使用小写名称创建,但它似乎不会删除小写的键。
当我尝试添加此外键时(虽然它仍然存在),我收到以下消息:
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0601N The name of the object to be created is identical to the existing
name "fk_keyname" of type "FOREIGN KEY". SQLSTATE=42710
有谁知道如何删除具有小写名称的外键?
mustaccio 的回答奏效了。尝试了各种报价,但这样就成功了:
db2 'alter table TABLENAME drop constraint "fk_keyname"'