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

不允許設(shè)置db2主鍵問(wèn)題的解決

數(shù)據(jù)庫(kù)
db2主鍵在設(shè)置時(shí),有時(shí)候會(huì)提示錯(cuò)誤,無(wú)法創(chuàng)建,下面就叫一個(gè)解決不允許設(shè)置db2主鍵的方法,供您參考學(xué)習(xí)。

設(shè)置db2主鍵問(wèn)題出錯(cuò)的話,應(yīng)該如何處理呢?下面就教您一個(gè)不允許設(shè)置db2主鍵問(wèn)題的解決方法,希望對(duì)您學(xué)習(xí)設(shè)置db2主鍵方面有所幫助。

將empno設(shè)置為主鍵

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  出現(xiàn)問(wèn)題的原因是,因?yàn)閑mpno列在創(chuàng)建的時(shí)候,默認(rèn)支持值為空。而在DB2中,針對(duì)這種情況,是不允許創(chuàng)建主鍵的。這點(diǎn)也與oracle和mysql不同。

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

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

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

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

解決辦法:

查看錯(cuò)誤信息代碼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.

。。。。。內(nèi)容省略。。。。。。。。

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

。。。。。內(nèi)容省略。。。。。。。。


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

通過(guò)查看上述描述中的紅色部分的文字,emp表的empno列是添加了not null約束而導(dǎo)致表出于了“reorg pending state”這種狀態(tài)。我們可以通過(guò)以下的方法來(lái)驗(yàn)證:

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.

查看下表的狀態(tài),若為normal則能夠正常得進(jìn)行操作:

db2 => load query table emp

Tablestate:

Normal

總結(jié):對(duì)表添加主鍵時(shí)出現(xiàn)的錯(cuò)誤,是由于之前對(duì)表的列進(jìn)行了修改,添加了非空約束,導(dǎo)致整個(gè)表出于“Reorg Pending”狀態(tài)。

針對(duì)表出現(xiàn)這種狀況時(shí),使用reorg table命令,將表進(jìn)行reorganize即可。
 

 

 

【編輯推薦】

DB2臨時(shí)表定義的方法

linux下安裝DB2的步驟

DB2性能優(yōu)化的十大注意事項(xiàng)

SQL SERVER連接DB2數(shù)據(jù)庫(kù)

DB2索引創(chuàng)建原則

責(zé)任編輯:段燃 來(lái)源: 互聯(lián)網(wǎng)
相關(guān)推薦

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-13 14:46:08

DB2 -964

2010-08-20 10:18:32

DB2自動(dòng)增長(zhǎng)主鍵

2010-08-10 17:10:46

2022-05-08 18:18:40

JDKValueHashMap

2009-09-22 15:54:42

CCIE筆試

2010-11-02 09:45:07

DB2 logfils

2010-08-03 13:23:47

DB2自動(dòng)增長(zhǎng)主鍵

2010-09-06 17:24:48

連接DB2數(shù)據(jù)庫(kù)

2010-08-19 13:14:17

DB2自動(dòng)增長(zhǎng)主鍵

2010-11-02 15:28:28

DB2 sequenc

2010-11-04 10:44:27

DB2 not fou

2010-08-16 15:37:37

DB2 -964問(wèn)題

2014-06-30 14:53:49

Android定制google

2020-08-20 11:12:14

iOS 13.6蘋(píng)果降級(jí)

2009-05-06 15:14:18

DB2日期時(shí)間
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)

主站蜘蛛池模板: 男女午夜免费视频 | 中文字幕四虎 | 免费在线观看av网址 | 日韩av视屏| 色永久 | 久久久日韩精品一区二区三区 | 99国产精品久久久 | 午夜电影网| 91精品国产乱码久久久 | 国产精品高潮呻吟久久久久 | 国产一区二区电影 | 成人精品鲁一区一区二区 | 色播久久久 | 亚洲精品9999久久久久 | 男女啪啪高潮无遮挡免费动态 | 亚洲福利在线观看 | 色婷婷精品久久二区二区蜜臂av | 91欧美| 国产精品亚洲片在线播放 | 成人av影院 | 亚洲国产欧美一区 | 精品久久久久久久 | h视频网站在线观看 | 国产影音先锋 | 国产一区二区日韩 | 日韩一区二区三区在线视频 | 免费的一级视频 | 福利网址 | 免费成年网站 | 一级黄色毛片 | 免费成人av网站 | 精品欧美乱码久久久久久1区2区 | 亚洲精品视频二区 | 91pron在线 | 日本黄色大片免费 | 国产精品中文字幕在线 | www.久草.com | 亚洲成人av| 欧美激情视频一区二区三区在线播放 | 天天综合久久 | 三级av在线 |