PostgreSQL/Constraints/Add Primary Key

Материал из SQL эксперт
Перейти к: навигация, поиск

Add primary key in table create statement

   <source lang="sql">

postgres=# postgres=# postgres=# CREATE TABLE "states" ( postgres(# "id" integer NOT NULL, postgres(# "name" text, postgres(# "abbreviation" character(2), postgres(# Constraint "state_pkey" Primary Key ("id") postgres(# ); NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "state_pkey" for table "states" CREATE TABLE postgres=# postgres=# drop table states; DROP TABLE postgres=#

      </source>