PRIMARY KEY
¶
The PRIMARY KEY constraint specifies that a column or columns of a table can contain only unique (non-duplicate), non-null values.
Using columns of type object
, geo_point
, geo_shape
or array
as
PRIMARY KEY is not supported.
To use a whole object
as PRIMARY KEY each column within the object
can
be declared as PRIMARY KEY instead.
Adding a PRIMARY KEY column is only possible if the table is empty.
Warning
The verification if the table is empty and the schema update isn’t atomic. That means that it could be possible to add a primary key column to a table that isn’t empty.
If that is the case queries that contain the primary key columns in the WHERE clause will not behave as expected.