CHAR vs GRAPHIC in DB2
db2 => describe table test
Data type Column
Column name schema Data type name Length Scale Nulls
------------------------------- --------- ------------------- ---------- ----- ------
NAME SYSIBM GRAPHIC 10 0 Yes
1 record(s) selected.
db2 => describe table test1
Data type Column
Column name schema Data type name Length Scale Nulls
------------------------------- --------- ------------------- ---------- ----- ------
NAME SYSIBM CHARACTER 10 0 Yes
1 record(s) selected.
如果插入英文字母,那麼都最多可以插入10個
db2 => insert into test values('helloworld')
DB20000I The SQL command completed successfully.
db2 => insert into test1 values('helloworld')
DB20000I The SQL command completed successfully.
插入漢字,最多可以插入幾個那?
db2 => insert into test values('插入十個漢字試試看吧')
DB20000I The SQL command completed successfully.
db2 => insert into test1 values('插入十個漢字試試看吧')
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0433N Value "插入十個漢字試試看吧" is too long. SQLSTATE=22001
GRAPHIC型別,那麼那個10就表示個數,無論是英文,漢字,日文,都是指的個數
CHAR型別定義的那個10表示的是位元組數,在UTF-8的編碼下,一個漢字佔用3個位元組
db2 => insert into test1 values('插入十g')
DB20000I The SQL command completed successfully.
db2 => insert into test1 values('插入十gh')
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0433N Value "插入十gh" is too long. SQLSTATE=22001
GRAPHIC型別有個好處,比如你用substr,你可以擷取到整個的字元,無論是什麼字元,都是整個的
但是CHAR型別,你很可能擷取到的字元是個亂碼
Data type Column
Column name schema Data type name Length Scale Nulls
------------------------------- --------- ------------------- ---------- ----- ------
NAME SYSIBM GRAPHIC 10 0 Yes
1 record(s) selected.
db2 => describe table test1
Data type Column
Column name schema Data type name Length Scale Nulls
------------------------------- --------- ------------------- ---------- ----- ------
NAME SYSIBM CHARACTER 10 0 Yes
1 record(s) selected.
如果插入英文字母,那麼都最多可以插入10個
db2 => insert into test values('helloworld')
DB20000I The SQL command completed successfully.
db2 => insert into test1 values('helloworld')
DB20000I The SQL command completed successfully.
插入漢字,最多可以插入幾個那?
db2 => insert into test values('插入十個漢字試試看吧')
DB20000I The SQL command completed successfully.
db2 => insert into test1 values('插入十個漢字試試看吧')
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0433N Value "插入十個漢字試試看吧" is too long. SQLSTATE=22001
GRAPHIC型別,那麼那個10就表示個數,無論是英文,漢字,日文,都是指的個數
CHAR型別定義的那個10表示的是位元組數,在UTF-8的編碼下,一個漢字佔用3個位元組
db2 => insert into test1 values('插入十g')
DB20000I The SQL command completed successfully.
db2 => insert into test1 values('插入十gh')
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0433N Value "插入十gh" is too long. SQLSTATE=22001
GRAPHIC型別有個好處,比如你用substr,你可以擷取到整個的字元,無論是什麼字元,都是整個的
但是CHAR型別,你很可能擷取到的字元是個亂碼
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/725820/viewspace-1968005/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle RAC vs DB2 PureScaleOracleDB2
- VS編譯器基礎 int main(int argc,char* argv[])編譯AIGC
- Core Graphic 指南:圓弧與路徑
- arcgis js:graphicLayer刪除特定的graphicJS
- VS C++ 2017中const char* 型別的值不能用於初始化char*的解決C++型別
- const char*, char const*, char*const的區別
- const char*, char const*, char*const 有何區別?
- C++中string、char *、char[]、const char*的轉換C++
- Determining whether an object requires reorganization MVS DB2ObjectUIDB2
- 關於VS2017中const char *不能用於初始化char *型別的實體的問題型別
- char str[]和char *str的區別
- 【VS2019 C++】"const char *" 型別的值不能用於初始化 "char *" 型別的實體C++型別
- 【筆記】VS2017中出現 "const char *" 型別的值不能用於初始化 "char *" 型別的實體筆記型別
- char *的使用
- 當char型變數遇上char*型的指標變數指標
- Graphic Inspector for mac(直觀的圖片檢視器)Mac
- VS中”LPTSTR" 型別的值不能用於初始化 "char *" 型別的實體型別
- VS2019【C++報錯】E0144"const char *" 型別的值不能用於初始化 "char *" 型別的實體C++型別
- Keynote模板外掛:Graphic Styles for Mac基礎功能介紹Mac
- char轉換成int
- oracle to_char 函式Oracle函式
- oracle to_char函式Oracle函式
- const char* 型別不能用於初始化char* 型別實體型別
- C++中char* const char* string 之間的轉換複習C++
- varchar和char的區別
- mysql char_length和lengthMySql
- char* 轉 LPCWSTR 解決方案
- CL_ABAP_CHAR_UTILITIES類
- 【基礎】ORACLE CHAR 與 VARCHAROracle
- const char*的全特化
- DB2:ksh: db2: not found.DB2
- Graphic Inspector for mac(mac影像檢查器) v2.4.10啟用版Mac
- DB2系列之DB2安裝DB2
- Qt中 QString,QByteArray,Qchar,const char* ,char *int 的用法及相互轉換QT
- C語言程式的內在分配:堆和棧以及char a[]和char*的區別C語言
- windows 字元訊息——WM_CHARWindows字元
- MySQL中CHAR和VARCHAR區別MySql
- 避免使用Oracle的char型別Oracle型別