0
我想通過命令行在DB2中刪除外鍵。我已經成功地在很多次,我相信,我使用了正確的語法: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"'