Create a table that references another table
suggest changeIn this example, the users table has a column that references the agencies table. Create the referenced table first.
CREATE TABLE agencies (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL
);
CREATE TABLE users (
id SERIAL PRIMARY KEY,
agency_id INTEGER NOT NULL REFERENCES agencies(id) DEFERRABLE INITIALLY DEFERRED
);
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents