简体   繁体   中英

DB2 table full name

I'm getting a little confused in db2 table naming. In db2 we have tablespace , schema , database name , username , table name , etc... .
My (silly) question is: When querying (ie select * from ???), what is the full and complete name of a table? As in some situations it doesn't work if I put just the table name . (ie tablespace and schema are also required.)
For example, in MySQL it is [database].[table]. But what about DB2?

Thanks a lot for your attention.

In DB2 you connect to a database and then select from a schema and table name

schema.tablename

For an end user that is it. In the background there can be crazy stuff going on with nicknames -- any surfaced schema.tablename can be an alias to anywhere else (even other servers with federation), but from the query point of view it is in that schema.tablename location.

tablespaces and indexspaces are used internally to map where the data is stored on the disk and only matters when you are creating the table.

bufferpools are used internally to map where the data is stored in memory and only matter when you create tablespaces.

Other objects (Views, Indexes, Stored Procedures, Functions, and Sequences) are just like tables

schema.<objectname>

Special Characters

In DB2 you can have special characters in names. You use " to around the special names

schema."tablename with space"

Quotes are also needed if you combine upper and lower case in your names. DB2 will convert to upper case if the name is declared in upper case so a leading practice is to use upper case and underscore in all names -- then you don't need to worry about quoting or matching case.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM