8.7. Constraints

Constraints are attributes of an object that are used to restrict certain events from happening. Using constraints will help you to prevent things from happening. Especially when you want to protect the integrity of your data, constraints will be essential. The constraints provided by PostgreSQL have to a large extent been defined in the ANSI standard, so using constraints should not affect the portability of your data structures significantly as long as the database you are porting your data structures to supports ANSI SQL-92 as well.

8.7.1. The CREATE TABLE Command and Constraints

In most cases, constraints are defined when creating tables. Therefore the CREATE TABLE command provides many options to define the right set of ...

Get PHP and PostgreSQL: Advanced Web Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.