Create tables with column types and constraints like NOT NULL, UNIQUE, CHECK, and DEFAULT. Use GENERATED ALWAYS AS IDENTITY for auto-incrementing primary keys. Constraints enforce data rules at the database level.
Creating Tables
CREATE TABLE users (
id SERIAL PRIMARY KEY,
name VARCHAR(100) NOT NULL,
email TEXT UNIQUE NOT NULL,
age INTEGER CHECK (age >= 0),
created TIMESTAMP DEFAULT NOW()
);