Study for the SQL Basics Test. Improve your knowledge with multiple choice questions and detailed explanations. Prepare effectively to master SQL concepts!

Multiple Choice

Which of the following creates a table with an inline primary key for id?

Inline primary key means you attach the constraint directly to the column in the same column definition, so the column becomes the primary key as you define it. In this case, defining id as INT and immediately marking it PRIMARY KEY makes id the table’s primary key right there, and it also implies not null and unique values automatically. This is exactly the inline form. The other forms differ in structure. Placing a separate table-level constraint like PRIMARY KEY (id) after all columns still creates the primary key, but it’s not inline with the column definition. The syntax attempting to write PRIMARY KEY id isn’t valid standard SQL for declaring a primary key. And declaring id as INT NOT NULL without any primary key leaves the table without a primary key.

Inline primary key means you attach the constraint directly to the column in the same column definition, so the column becomes the primary key as you define it. In this case, defining id as INT and immediately marking it PRIMARY KEY makes id the table’s primary key right there, and it also implies not null and unique values automatically. This is exactly the inline form.

The other forms differ in structure. Placing a separate table-level constraint like PRIMARY KEY (id) after all columns still creates the primary key, but it’s not inline with the column definition. The syntax attempting to write PRIMARY KEY id isn’t valid standard SQL for declaring a primary key. And declaring id as INT NOT NULL without any primary key leaves the table without a primary key.