Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save oliviermarin/50ed04815d33000b80d28f85f7726bf6 to your computer and use it in GitHub Desktop.
Save oliviermarin/50ed04815d33000b80d28f85f7726bf6 to your computer and use it in GitHub Desktop.
SQL | PostrgreSQL | Add a FOREIGN-KEY column in table t1 from table t2
ALTER TABLE t1
ADD COLUMN t1_fk INTEGER DEFAULT 1,
ADD FOREIGN KEY(t1_fk) REFERENCES t2(t2_pk);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment