Sample Exam Questions
※This sample exam is different from those that appear in the actual OSS-DB Exam.
2024/05/01
Tablespaces are physical places for tables, indexes, and so on. By default, all objects are placed under the directories that make up the database cluster, but you can create tablespaces to place objects elsewhere.
For example, you might want to use tablespaces when you run out of disk space and want to add another partition to store your data, or when you want to place frequently used tables or indexes in faster storage.
In PostgreSQL, you can specify a directory as a tablespace. For example, if the tablespace to be created is named my_tablespace and the directory to be used is /path/to/my_tablespace, then you would create it with the command CREATE TABLESPACE my_tablespace LOCATION ‘/path/to/my_tablespace’. However, CREATE TABLESPACE does not execute mkdir internally, so you must create this directory beforehand, and it must be empty. On Linux, you would execute the following commands as a root user:
mkdir /path/to/my_tablespace
chown postgres /path/to/my_tablespace
chmod 700 /path/to/my_tablespace
When executing CREATE TABLE, the default tablespace is used unless otherwise specified. However, if you execute it as CREATE TABLE my_table(...) TABLESPACE my_tablespace, my_tablespace will be used.
There is also a parameter called default_tablespace, so if you do:
SET default_tablespace = my_tablespace;
CREATE TABLE my_table(...);
my_tablespace will be used.
Superuser privileges are required to create a tablespace, but just creating it does not allow regular users to create objects in the tablespace. To create an object, you need to grant CREATE privileges on the tablespace, as in:
GRANT CREATE ON TABLESPACE my_tablespace TO somebody;
To drop a tablespace, use the DROP TABLESPACE command, but the tablespace must be empty to execute. If any objects are present, they must first be deleted or moved to another tablespace.
This is a question where you need to select the incorrect option, so the correct answer is E.
© EDUCO All Rights Reserved.