答案:
如何在DB2的表中插入特殊的字符
在實際的使用中可能會遇到要在表的字段中插入特殊字符的問題,我在此簡單
的總結一下,歡迎大家繼續﹐以便和大家共享﹐共同探討﹐共同近步﹗(以下主要以
DB2 7.X為例)。
1. 插入字符 ' (單引號 )
INSERT INTO DB2ADMIN.AAAA VALUES('''');
INSERT INTO DB2ADMIN.AAAA VALUES('A''''B');
2. 插入字符 ~
INSERT INTO DB2ADMIN.AAAA VALUES('~');
INSERT INTO DB2ADMIN.AAAA VALUES('A~B');
3. 插入字符 !
INSERT INTO DB2ADMIN.AAAA VALUES('!');
INSERT INTO DB2ADMIN.AAAA VALUES('A!B');
4. 插入字符 @
INSERT INTO DB2ADMIN.AAAA VALUES('@');
INSERT INTO DB2ADMIN.AAAA VALUES('A@B');
5. 插入字符 #
INSERT INTO DB2ADMIN.AAAA VALUES('#');
INSERT INTO DB2ADMIN.AAAA VALUES('A#B');
6. 插入字符 $
INSERT INTO DB2ADMIN.AAAA VALUES('$');
INSERT INTO DB2ADMIN.AAAA VALUES('A$B');
7. 插入字符 %
INSERT INTO DB2ADMIN.AAAA VALUES('%');
INSERT INTO DB2ADMIN.AAAA VALUES('A%B');
8. 插入字符 ^
INSERT INTO DB2ADMIN.AAAA VALUES('^');
INSERT INTO DB2ADMIN.AAAA VALUES('A^B');
9. 插入字符 &
INSERT INTO DB2ADMIN.AAAA VALUES('&');
INSERT INTO DB2ADMIN.AAAA VALUES('A&B');
10. 插入字符 *
INSERT INTO DB2ADMIN.AAAA VALUES('*');
INSERT INTO DB2ADMIN.AAAA VALUES('A*B');
11. 插入字符 (
INSERT INTO DB2ADMIN.AAAA VALUES('(');
INSERT INTO DB2ADMIN.AAAA VALUES('A(B');
12. 插入字符 )
INSERT INTO DB2ADMIN.AAAA VALUES(')');
INSERT INTO DB2ADMIN.AAAA VALUES('A)B');
13. 插入字符 _
INSERT INTO DB2ADMIN.AAAA VALUES('_');
INSERT INTO DB2ADMIN.AAAA VALUES('A_B');
14. 插入字符 -
INSERT INTO DB2ADMIN.AAAA VALUES('-');
INSERT INTO DB2ADMIN.AAAA VALUES('A-B');
15. 插入字符 +
INSERT INTO DB2ADMIN.AAAA VALUES('+');
INSERT INTO DB2ADMIN.AAAA VALUES('A+B');
16. 插入字符 =
INSERT INTO DB2ADMIN.AAAA VALUES('=');
INSERT INTO DB2ADMIN.AAAA VALUES('A=B');
17. 插入字符 /
INSERT INTO DB2ADMIN.AAAA VALUES('/');
INSERT INTO DB2ADMIN.AAAA VALUES('A/B');
18. 插入字符 <
INSERT INTO DB2ADMIN.AAAA VALUES('<');
INSERT INTO DB2ADMIN.AAAA VALUES('A<B');
19. 插入字符 >
INSERT INTO DB2ADMIN.AAAA VALUES('>');
INSERT INTO DB2ADMIN.AAAA VALUES('A>B');
20. 插入字符 ?
INSERT INTO DB2ADMIN.AAAA VALUES('?');
INSERT INTO DB2ADMIN.AAAA VALUES('A?B');
21. 插入字符 :
INSERT INTO DB2ADMIN.AAAA VALUES(':');
INSERT INTO DB2ADMIN.AAAA VALUES('A:B');
22. 插入字符 ;
INSERT INTO DB2ADMIN.AAAA VALUES(CHR(59));
INSERT INTO DB2ADMIN.AAAA VALUES(ACHR(59)B);
23. 插入字符 '
INSERT INTO DB2ADMIN.AAAA VALUES('''');
INSERT INTO DB2ADMIN.AAAA VALUES('A''''B');
24. 插入字符 `
INSERT INTO DB2ADMIN.AAAA VALUES('`');
INSERT INTO DB2ADMIN.AAAA VALUES('A`B');
25. 插入字符 |
INSERT INTO DB2ADMIN.AAAA VALUES('|');
INSERT INTO DB2ADMIN.AAAA VALUES('A|B');
26. 插入字符 \
INSERT INTO DB2ADMIN.AAAA VALUES('\');
INSERT INTO DB2ADMIN.AAAA VALUES('A\B');
27. 插入字符 {
INSERT INTO DB2ADMIN.AAAA VALUES('{');
INSERT INTO DB2ADMIN.AAAA VALUES('A{B');
28. 插入字符 }
INSERT INTO DB2ADMIN.AAAA VALUES('}');
INSERT INTO DB2ADMIN.AAAA VALUES('A}B');
29. 插入字符 [
INSERT INTO DB2ADMIN.AAAA VALUES('[');
INSERT INTO DB2ADMIN.AAAA VALUES('A[B');
30. 插入字符 ]
INSERT INTO DB2ADMIN.AAAA VALUES(']');
INSERT INTO DB2ADMIN.AAAA VALUES('A]B');
待續...
上一个:DB2中的限制之一SQL標識符的長度限制
下一个:IBM推出能自主和优化信息分析的新DB2软件