Skip to content
Search

PostgreSQL:Constraints

lastmod 2024-02-22created 2023-07-163 edits

Constraints

Character length limit

When you create the table you can do something of this sort,

CREATE TABLE names (
  name text CONSTRAINT namechk CHECK (char_length(name) <= 255)
)

(namechk is just a name for the constraint)

Same goes for ALTER TABLE for example:

ALTER TABLE names
  ADD CONSTRAINT namechk CHECK (char_length(name) <= 255);

Check Constraints

on delete cascade

on update cascade

See also

Favorite site

author Zer0 sitemap