1

I can not figure out what is the difference between schema and database in db2 I find this SQL so confusing for example :

CREATE TABLE schema1.table1
 ....
 ....
 ....
IN database1.tabspace1

Can we say that the database in this case contains the tabspace whereas the schema contains the tables?

6

This simple question has caused an unusual amount of debate, and I feel compelled to quote an authoritative source.

The database stores all data in tables that are related to one another. Relationships are established between tables such that data is shared and duplication is minimized.

A table space is a storage structure containing tables, indexes, large objects, and long data. They are used to organize data in a database into logical storage groupings that relate to where data is stored on a system.

A schema is a collection of named objects; it provides a way to group those objects logically. A schema is also a name qualifier; it provides a way to use the same natural name for several objects, and to prevent ambiguous references to those objects.

| improve this answer | |
2

A database is a collection of schemas, a schema is a collection of tables/views/UDF/...

| improve this answer | |
  • Not very verbose, but seems correct. Why is this down voted? – Lennart May 2 '16 at 9:56
-1

schema = namespace within database, identical to user account database = single database

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.