Primary keys - the basics
Single-column primary keys
Multicolumn primary keys
Auto-increment columns and sequences
20. Creating columns with IDENTITY
Revision

Instruction

Good. Everything works well. Now it's your turn to create a table with an IDENTITY column. Remember to put that information as the column type!

Exercise

Create a table called cinema with the following columns:

  • cinema_id - integer with consecutive numbers automatically generated, it's also the primary key,
  • name - up to 30 characters,
  • city - up to 30 characters.

Stuck? Here's a hint!

Type

CREATE TABLE cinema (
   cinema_id IDENTITY PRIMARY KEY,
   name varchar(30),
   city varchar(30)
); 

Console

Code editor

Result

TableConsole