成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

不允許設置db2主鍵問題的解決

數據庫
db2主鍵在設置時,有時候會提示錯誤,無法創建,下面就叫一個解決不允許設置db2主鍵的方法,供您參考學習。

設置db2主鍵問題出錯的話,應該如何處理呢?下面就教您一個不允許設置db2主鍵問題的解決方法,希望對您學習設置db2主鍵方面有所幫助。

將empno設置為主鍵

db2 => alter table emp add primary key (empno)

DB21034E The command was processed as an SQL statement because it was not a

valid Command Line Processor command. During SQL processing it returned:

SQL0542N "EMPNO" cannot be a column of a primary key or unique key because it

can contain null values. SQLSTATE=42831

fenced  出現問題的原因是,因為empno列在創建的時候,默認支持值為空。而在DB2中,針對這種情況,是不允許創建主鍵的。這點也與oracle和mysql不同。

fenced  因此,我們要添加主鍵,需要先修改empno,添加上約束,讓此列為非空:

db2 => alter table emp alter column empno set not null

將列修改了之后,嘗試添加主鍵,再次出錯:

db2 => alter table emp add primary key (empno)

DB21034E The command was processed as an SQL statement because it was not a

valid Command Line Processor command. During SQL processing it returned:

SQL0668N Operation not allowed for reason code "7" on table "DB2INST1.EMP".

SQLSTATE=57016

解決辦法:

查看錯誤信息代碼SQL0668N,去查看具體的code“7”的含義。

db2 => ? SQL0668N

SQL0668N Operation not allowed for reason code "<reason-code>" on table

     "<table-name>".

Explanation:

Access to table "<table-name>" is restricted. The cause is based on the

following reason codes "<reason-code>":

1fenced

fenced  The table is in the Set Integrity Pending No Access state.

。。。。。內容省略。。。。。。。。

7fencedThe table is in the reorg pending state. This can occur after

fenced  an ALTER TABLE statement containing a REORG-recommended

fenced  operation.

User response:

1fencedExecute the SET INTEGRITY statement with the IMMEDIATE CHECKED

fenced  option on table "<table-name>" to bring the table out of the

。。。。。內容省略。。。。。。。。


7fencedReorganize the table using the REORG TABLE command.

fenced  For a table in the reorg pending state, note that the following

fenced  clauses are not allowed when reorganizing the table:

fenced  

fenced  * The INPLACE REORG TABLE clause

fenced  * The ON DATA PARTITION clause for a partitioned table when

fenced     table has nonpartitioned indexes defined on the table

通過查看上述描述中的紅色部分的文字,emp表的empno列是添加了not null約束而導致表出于了“reorg pending state”這種狀態。我們可以通過以下的方法來驗證:

db2 => load query table emp

Tablestate:

Reorg Pending

解決辦法,參照6.1中的“User response”描述,使用REORG TABLE命令:

db2 => reorg table emp

DB20000I The REORG command completed successfully.

修改完成后,再次添加主鍵:

db2 => alter table emp add primary key(empno)

DB20000I The SQL command completed successfully.

查看下表的狀態,若為normal則能夠正常得進行操作:

db2 => load query table emp

Tablestate:

Normal

總結:對表添加主鍵時出現的錯誤,是由于之前對表的列進行了修改,添加了非空約束,導致整個表出于“Reorg Pending”狀態。

針對表出現這種狀況時,使用reorg table命令,將表進行reorganize即可。
 

 

 

【編輯推薦】

DB2臨時表定義的方法

linux下安裝DB2的步驟

DB2性能優化的十大注意事項

SQL SERVER連接DB2數據庫

DB2索引創建原則

責任編輯:段燃 來源: 互聯網
相關推薦

2011-03-01 14:12:12

FreebsdProftpd

2010-05-20 13:03:52

IIS父路徑

2010-06-01 16:12:00

2023-08-22 20:43:09

HashMap單線程null

2010-11-11 16:53:28

SQL Server視

2010-08-20 10:18:32

DB2自動增長主鍵

2010-08-10 17:10:46

2010-08-13 14:46:08

DB2 -964

2022-05-08 18:18:40

JDKValueHashMap

2009-09-22 15:54:42

CCIE筆試

2010-11-02 09:45:07

DB2 logfils

2010-08-19 13:14:17

DB2自動增長主鍵

2010-11-02 15:28:28

DB2 sequenc

2010-08-03 13:23:47

DB2自動增長主鍵

2010-09-06 17:24:48

連接DB2數據庫

2010-11-04 10:44:27

DB2 not fou

2010-08-16 15:37:37

DB2 -964問題

2014-06-30 14:53:49

Android定制google

2020-08-20 11:12:14

iOS 13.6蘋果降級

2012-12-07 10:19:56

IBMdW
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 一级片在线免费播放 | 91视频国产区 | 国产成人精品一区二区三区在线 | 欧美一级欧美三级在线观看 | 国产国拍亚洲精品av | 欧美中文字幕在线观看 | 免费久草 | 国产精品国产三级国产aⅴ中文 | 91一区二区 | 精品自拍视频在线观看 | 中文在线一区二区 | 久久精品亚洲精品国产欧美 | 日韩欧美国产综合 | 69精品久久久久久 | 久久福利 | 亚洲综合色视频在线观看 | 精品国产乱码久久久久久丨区2区 | 久久久久国产 | 国产98色在线 | 日韩 | 午夜天堂精品久久久久 | 久久久久亚洲精品中文字幕 | 久久高潮| 欧美日韩一区在线播放 | 亚洲 欧美 日韩 在线 | 久草热8精品视频在线观看 午夜伦4480yy私人影院 | 天天射天天操天天干 | 色综合成人网 | 操人网站 | 亚洲国产精品一区二区第一页 | 日韩av电影院 | 波多野结衣二区 | 2020亚洲天堂 | 欧美日日| 99爱在线免费观看 | 欧美日韩一区二区三区四区五区 | 欧美在线视频网 | 亚洲36d大奶网 | 亚洲欧美日韩在线 | 亚洲欧美中文日韩在线v日本 | 欧美一级欧美三级在线观看 | 日本爱爱|