DB2中表名是分大小写的,如果创建表的时候,指定的是小写,那么DB2会自动转化为大写
下面示例中,创建表的时候,都是“小写”,但第一个表被转换为了大写:
db2 => create table lowercaseone(id int)DB20000I The SQL command completed successfully.db2 => create table "lowercasetwo"(id int)DB20000I The SQL command completed successfully.db2 => list tablesTable/View Schema Type Creation time ------------------------------- --------------- ----- --------------------------LOWERCASEONE E105Q5A T 2017-03-13-11.17.19.338368lowercasetwo E105Q5A T 2017-03-13-11.17.45.270534 2 record(s) selected.
如果想要访问这些小写名的表,必须要用双引号把表名括上。如果不在DB2交互模式下,引号前面可以加上转义符
$ db2 "insert into lowercasetwo values(100)"DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command. During SQL processing it returned:SQL0204N "E105Q5A.LOWERCASETWO" is an undefined name. SQLSTATE=42704$ db2 "insert into "lowercasetwo" values(100)"DB20000I The SQL command completed successfully.$ db2(c) Copyright IBM Corporation 1993,2007Command Line Processor for DB2 Client 10.5.5To exit db2 interactive mode, type QUIT at the command prompt. Outside interactive mode, all commands must be prefixed with '
db2'
.To list the current command option settings, type LIST COMMAND OPTIONS.For more detailed help, refer to the Online Reference Manual.db2 => select * from "lowercasetwo"ID ----------- 100 1 record(s) selected.