Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A database schema vs a database tablespace?

Doing my databases reading when I read...

Schema: Is a container for objects

Tablespace: A logical storage unit for objects

Can anyone explain the difference between these?

like image 485
Carson Wood Avatar asked Jan 31 '16 22:01

Carson Wood


People also ask

What is the difference between a database schema and a database?

Key Differences between Database and Schema The fundamental difference between them is that the database is an organized collection of interrelated data or information about the considered object. In contrast, the schema is a logical representation or description of an entire database.

What is the difference between tablespace and database?

DATABASES's data are stored in logical storage units called TABLESPACES. A database may contain "one or more" tablespaces. A tablespace may contain one or more datafiles. A database's data is collectively stored in the datafiles that constitute each tablespace of the database.

Is tablespace same as schema in Oracle?

The Oracle database stores a schema object logically within a tablespace. There is no relationship between database schemas and a tablespace: a tablespace can contain objects from different schemas, and objects from a database schema can be contained in different tablespaces.

What is difference between schema and database in Oracle?

A schema is a collection of objects (such as tables, indexes or procedures). Every object belongs to exactly one schema, and every schema is a part of exactly one database. (Names may not be unique, however.


1 Answers

A schema is a namespace - a logical thing. It is used to organize the names of database objects. It has nothing to do with the way the data is stored.

A tablespace is a physical thing. It's a container for data and has nothing to do with the logical organization of the database objects.

A single object (e.g. a table) could be spread across multiple tablespaces (depending on the DBMS being used) but it can only be defined in a single schema. The table schema_1.table_1 is a different table than schema_2.table_1 - although the "plain" name is the same, the fully qualified name is different and therefore those are two different tables.

Objects that are organized in the same schema are not necessarily stored in the same tablespace. And a single tablespace can contain objects from different schemas.

Schemas (and catalogs, which are another level of namespace) are part of the SQL language and are defined in the SQL standard.

Tablespaces are part of the physical storage and are DBMS-specific (although nearly all DBMS support a concept like that) and are not part of the SQL query language (as defined by the SQL standard). They are, however, defined and managed through vendor-specific SQL/DDL statements.

like image 108
a_horse_with_no_name Avatar answered Sep 19 '22 01:09

a_horse_with_no_name