Sample Exam Questions
create table test (primary key id integer, val varchar(50));
create table test (id integer primary key, val varchar(50));
create table test (id integer, val varchar(50), constraint id primary key);
create table test (id integer, val varchar(50), primary key (id));
create table test (id integer, val varchar(50), primary key = id);
※This sample exam is different from those that appear in the actual OSS-DB Exam.
2024/05/02
The basic syntax for creating a table with the CREATE TABLE command is as follows:
create table table_name (column_definition, column_definition... [, table_constraints])
There are constraints that can only be specified as column constraints, such as the NOT NULL constraint, constraints that can only be specified as table constraints, such as the CHECK constraint, and constraints that can be specified as either column or table constraints, such as the PRIMARY KEY, UNIQUE, and foreign key constraints.
Column constraints are written by appending the constraint to the column definition, which consists of a column name and data type. For a primary key, you simply write 'primary key'.
Table constraints are written after all column definitions, separated by a comma. For a primary key, you specify it in the format 'primary key (key_column)'. If the primary key is a single column, it can be written as either a column constraint or a table constraint. However, if the primary key is a combination of multiple columns, it must be written as a table constraint.
Therefore, the correct answers are B and D.
© EDUCO All Rights Reserved.