Sample Exam Questions

From the objective of OSS-DB Exam Silver
S3.1 SQL commands (Table definition)

Sample Question

3.10

Choose one that cannot be changed by ALTER TABLE.

  1. Name of the table
  2. Owner of the table
  3. Name of the column
  4. Data type of the column
  5. Order of the columns
     

※This sample exam is different from those that appear in the actual OSS-DB Exam.
2024/05/01

Answer and Explanation

While it is ideal to carefully design your table definitions in advance and make as few changes as possible after creating them with CREATE TABLE, the ALTER TABLE command is available for when changes are necessary, allowing you to modify most of the elements that can be specified with CREATE TABLE.
To change the name of a table, you would use ALTER TABLE old_name RENAME TO new_name. To change the owner, you would use ALTER TABLE table_name OWNER TO new_owner.
The name of a column can be changed with ALTER TABLE old_name RENAME old_column_name TO new_column_name.
The data type of a column can be changed with ALTER TABLE table_name ALTER column_name SET DATA TYPE new_type.
The order of the columns, which affects the order in which they are displayed when performing a search like SELECT * FROM table_name, cannot be changed with ALTER TABLE in PostgreSQL (although some RDBMSs do allow this). The order of column display is controlled by explicitly specifying the columns, as in SELECT column1, column2...


So the correct answer is E.


Of course, caution is required when executing ALTER TABLE due to its potential to significantly impact existing data. Additionally, it's important to note that there can be many subtle differences in syntax between different types of RDBMSs.