DB2隱藏列
DB2從9.5以後引入了隱藏列,就是你用select * from table的方式查詢不到這個列,但是可以顯式的指定列名來看該列的值。
CREATE TABLE CUSTOMER
(
CUSTNO INTEGER NOT NULL,
CUST_NAME VARCHAR(50),
CUST_INFOCHANGE TIMESTAMP NOT NULL IMPLICITLY HIDDEN GENERATED BY DEFAULT FOR EACH ROW ON UPDATE AS ROW CHANGE TIMESTAMP
)
插入資料的時候,不用指定隱藏列
INSERT INTO CUSTOMER VALUES(1,'111')
INSERT INTO CUSTOMER VALUES(2,'222')
INSERT INTO CUSTOMER VALUES(3,'333')
INSERT INTO CUSTOMER VALUES(4,'444')
隱藏列的值在這裡是插入的時間戳,如果你更新一行,那麼這個時間戳也是相應改變的。
describe 表是可以看到這個隱藏列的
db2 => describe table customer
Data type Column
Column name schema Data type name Length Scale Nulls
------------------------------- --------- ------------------- ---------- ----- ------
CUSTNO SYSIBM INTEGER 4 0 No
CUST_NAME SYSIBM VARCHAR 50 0 Yes
CUST_INFOCHANGE SYSIBM TIMESTAMP 10 6 No
3 record(s) selected.
可以顯式的檢視隱藏列
db2 => select CUSTNO,CUST_NAME,CUST_INFOCHANGE from customer
CUSTNO CUST_NAME CUST_INFOCHANGE
----------- -------------------------------------------------- --------------------------
1 111 2015-11-26-07.41.52.610475
2 222 2015-11-26-07.41.52.623278
3 333 2015-11-26-07.41.52.898431
4 444 2015-11-26-07.41.53.674208
4 record(s) selected.
但是使用select *就看不到這個列,這就是為什麼叫隱藏列的原因吧,因為這種情況下看不到
db2 => select * from customer
CUSTNO CUST_NAME
----------- --------------------------------------------------
1 111
2 222
3 333
4 444
4 record(s) selected.
匯出匯入資料實驗
export to customer.del of del modified by implicitlyhiddeninclude select * from customer
load from customer.del of del modified by implicitlyhiddeninclude identityoverride replace into customer nonrecoverable
但是這裡有個問題,還是需要繼續查一下,如果在定義此列的時候使用的是ALWAYS的方式
CUST_INFOCHANGE TIMESTAMP NOT NULL IMPLICITLY HIDDEN GENERATED ALWAYS FOR EACH ROW ON UPDATE AS ROW CHANGE TIMESTAMP
在執行load命令的時候會出現問題。
db2 => load from customer.del of del modified by implicitlyhiddeninclude identityoverride replace into customer nonrecoverable
SQL3551W The table contains at least one GENERATED ALWAYS column that the
utility will override.
SQL3109N The utility is beginning to load data from file
"/home/db2inst1/customer.del".
SQL3500W The utility is beginning the "LOAD" phase at time "11/26/2015
07:39:05.270055".
SQL3519W Begin Load Consistency Point. Input record count = "0".
SQL3520W Load Consistency Point was successful.
SQL3550W The field value in row "F0-1" and column "3" is not NULL, but the
target column has been defined as GENERATED ALWAYS.
SQL3185W The previous error occurred while processing data from row "F0-1" of
the input file.
SQL3550W The field value in row "F0-2" and column "3" is not NULL, but the
target column has been defined as GENERATED ALWAYS.
SQL3185W The previous error occurred while processing data from row "F0-2" of
the input file.
SQL3550W The field value in row "F0-3" and column "3" is not NULL, but the
target column has been defined as GENERATED ALWAYS.
SQL3185W The previous error occurred while processing data from row "F0-3" of
the input file.
SQL3550W The field value in row "F0-4" and column "3" is not NULL, but the
target column has been defined as GENERATED ALWAYS.
SQL3185W The previous error occurred while processing data from row "F0-4" of
the input file.
SQL3227W Record token "F0-1" refers to user record number "1".
SQL3227W Record token "F0-2" refers to user record number "2".
SQL3227W Record token "F0-3" refers to user record number "3".
SQL3227W Record token "F0-4" refers to user record number "4".
SQL3110N The utility has completed processing. "4" rows were read from the
input file.
SQL3519W Begin Load Consistency Point. Input record count = "4".
SQL3520W Load Consistency Point was successful.
SQL3515W The utility has finished the "LOAD" phase at time "11/26/2015
07:39:05.317399".
SQL3107W At least one warning message was encountered during LOAD processing.
Number of rows read = 4
Number of rows skipped = 0
Number of rows loaded = 0
Number of rows rejected = 4
Number of rows deleted = 0
Number of rows committed = 4
CREATE TABLE CUSTOMER
(
CUSTNO INTEGER NOT NULL,
CUST_NAME VARCHAR(50),
CUST_INFOCHANGE TIMESTAMP NOT NULL IMPLICITLY HIDDEN GENERATED BY DEFAULT FOR EACH ROW ON UPDATE AS ROW CHANGE TIMESTAMP
)
插入資料的時候,不用指定隱藏列
INSERT INTO CUSTOMER VALUES(1,'111')
INSERT INTO CUSTOMER VALUES(2,'222')
INSERT INTO CUSTOMER VALUES(3,'333')
INSERT INTO CUSTOMER VALUES(4,'444')
隱藏列的值在這裡是插入的時間戳,如果你更新一行,那麼這個時間戳也是相應改變的。
describe 表是可以看到這個隱藏列的
db2 => describe table customer
Data type Column
Column name schema Data type name Length Scale Nulls
------------------------------- --------- ------------------- ---------- ----- ------
CUSTNO SYSIBM INTEGER 4 0 No
CUST_NAME SYSIBM VARCHAR 50 0 Yes
CUST_INFOCHANGE SYSIBM TIMESTAMP 10 6 No
3 record(s) selected.
可以顯式的檢視隱藏列
db2 => select CUSTNO,CUST_NAME,CUST_INFOCHANGE from customer
CUSTNO CUST_NAME CUST_INFOCHANGE
----------- -------------------------------------------------- --------------------------
1 111 2015-11-26-07.41.52.610475
2 222 2015-11-26-07.41.52.623278
3 333 2015-11-26-07.41.52.898431
4 444 2015-11-26-07.41.53.674208
4 record(s) selected.
但是使用select *就看不到這個列,這就是為什麼叫隱藏列的原因吧,因為這種情況下看不到
db2 => select * from customer
CUSTNO CUST_NAME
----------- --------------------------------------------------
1 111
2 222
3 333
4 444
4 record(s) selected.
匯出匯入資料實驗
export to customer.del of del modified by implicitlyhiddeninclude select * from customer
load from customer.del of del modified by implicitlyhiddeninclude identityoverride replace into customer nonrecoverable
但是這裡有個問題,還是需要繼續查一下,如果在定義此列的時候使用的是ALWAYS的方式
CUST_INFOCHANGE TIMESTAMP NOT NULL IMPLICITLY HIDDEN GENERATED ALWAYS FOR EACH ROW ON UPDATE AS ROW CHANGE TIMESTAMP
在執行load命令的時候會出現問題。
db2 => load from customer.del of del modified by implicitlyhiddeninclude identityoverride replace into customer nonrecoverable
SQL3551W The table contains at least one GENERATED ALWAYS column that the
utility will override.
SQL3109N The utility is beginning to load data from file
"/home/db2inst1/customer.del".
SQL3500W The utility is beginning the "LOAD" phase at time "11/26/2015
07:39:05.270055".
SQL3519W Begin Load Consistency Point. Input record count = "0".
SQL3520W Load Consistency Point was successful.
SQL3550W The field value in row "F0-1" and column "3" is not NULL, but the
target column has been defined as GENERATED ALWAYS.
SQL3185W The previous error occurred while processing data from row "F0-1" of
the input file.
SQL3550W The field value in row "F0-2" and column "3" is not NULL, but the
target column has been defined as GENERATED ALWAYS.
SQL3185W The previous error occurred while processing data from row "F0-2" of
the input file.
SQL3550W The field value in row "F0-3" and column "3" is not NULL, but the
target column has been defined as GENERATED ALWAYS.
SQL3185W The previous error occurred while processing data from row "F0-3" of
the input file.
SQL3550W The field value in row "F0-4" and column "3" is not NULL, but the
target column has been defined as GENERATED ALWAYS.
SQL3185W The previous error occurred while processing data from row "F0-4" of
the input file.
SQL3227W Record token "F0-1" refers to user record number "1".
SQL3227W Record token "F0-2" refers to user record number "2".
SQL3227W Record token "F0-3" refers to user record number "3".
SQL3227W Record token "F0-4" refers to user record number "4".
SQL3110N The utility has completed processing. "4" rows were read from the
input file.
SQL3519W Begin Load Consistency Point. Input record count = "4".
SQL3520W Load Consistency Point was successful.
SQL3515W The utility has finished the "LOAD" phase at time "11/26/2015
07:39:05.317399".
SQL3107W At least one warning message was encountered during LOAD processing.
Number of rows read = 4
Number of rows skipped = 0
Number of rows loaded = 0
Number of rows rejected = 4
Number of rows deleted = 0
Number of rows committed = 4
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/725820/viewspace-1847466/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle 隱藏列Oracle
- iOS隱藏狀態列iOS
- OSX中隱藏和顯示[隱藏檔案]的命令列命令列
- win10怎樣隱藏工作列_win10全屏工作列隱藏操作方法Win10
- 工作列隱藏了怎麼還原 電腦隱藏了工作列怎麼恢復
- 函式索引產生隱藏列函式索引
- win10工作列如何取消隱藏_win10電腦工作列怎麼取消隱藏Win10
- win10平板模式怎麼隱藏工作列_wom10平板模式工作列隱藏如何操作Win10模式
- 如何隱藏工作列的圖示win10_win10怎麼隱藏狀態列圖示Win10
- Android 隱藏系統狀態列Android
- jquery easyui datagrid 動態隱藏列jQueryUI
- Ant Design Vue 的 table 隱藏特定列Vue
- jqgrid動態顯示,隱藏指定列
- win10工作列怎麼隱藏起來_windows10如何隱藏工作列Win10Windows
- win10隱藏工作列圖示怎麼設定 win10隱藏工作列圖示方法介紹Win10
- MAC如何顯示隱藏檔案和隱藏隱藏檔案的命令Mac
- 眼見為實,看看MySQL中的隱藏列!MySql
- 隱藏ip
- 隱藏索引索引
- 電腦工作列隱藏了怎麼顯示出來 win10電腦工作列隱藏怎麼調出來Win10
- MacOS X隱藏和顯示隱藏檔案Mac
- Mac顯示和隱藏“隱藏檔案”命令Mac
- 隱藏資料夾怎麼取消隱藏 關閉隱藏檔案的辦法
- 如何隱藏你的 Linux 的命令列歷史Linux命令列
- Windows XP 清除工作列隱藏圖示記錄(轉)Windows
- vue3 el-table控制列顯示隱藏Vue
- Mac下顯示和隱藏隱藏檔案的命令Mac
- Android 顯示、隱藏狀態列和導航欄Android
- C# 顯示、隱藏視窗對應的工作列C#
- Element ui的Table元件的列的顯示於隱藏UI元件
- Mac作業系統命令列顯示/隱藏檔案Mac作業系統命令列
- ios開發筆記--狀態列的自定義,隱藏iOS筆記
- mac顯示隱藏檔案,取消顯示隱藏檔案Mac
- 隱藏index.phpIndexPHP
- Cobalt Strike特徵隱藏特徵
- CSS隱藏元素方法CSS
- Nginx隱藏版本號Nginx
- python 隱藏彩蛋Python