Sample Exam Questions

From the objective of OSS-DB Exam Silver
- Development/SQL - SQL command
(table definition)

Sample Question

3.02

Choose the correct way to create a table with the id
column as the primary key.

  1. CREATE TABLE test (PRIMARY KEY id INTEGER, value TEXT);
  2. CREATE TABLE test (id INTEGER PRIMARY KEY, value TEXT);
  3. CREATE TABLE test (id INTEGER, value TEXT, PRIMARY KEY = id);
  4. CREATE TABLE test (id INTEGER, value TEXT, PRIMARY KEY id);
  5. CREATE TABLE test (id INTEGER, value TEXT, PRIMARY KEY (id));

※This sample exam is different from those that appear in the actual OSS-DB Exam.
2018/04/07

Answer and Explanation

A constraint on a primary key (PRIMARY KEY) can be defined as a column constraint or a table constraint, but if a combination of two or more columns is a primary key, it is defined as a table constraint.

When it is defined as a column constraint, write it as PRIMARY KEY following the data definition of the column name and column as in option B.

The table constraint is described after all column definitions, but in this case, as in choice E, describe the list of columns to be subject to the primary key after PRIMARY KEY in parentheses. Parentheses are required even if there is only one target column as in this example.

Therefore, the correct answers are B and E.