I don't use Postgres much (I used to use other DB's) so recently I was viewing a db in pgAdmin and saw an odd schema syntax which I can't find anything on the documentation and want to know a bit about it:
So I see this syntax:
CREATE TABLE table1
(
table1_id serial NOT NULL,
table2_fk_id t2_id NOT NULL, -- what is this line?
...
CONSTRAINT fk_table2_chm FOREIGN KEY (table2_fk_id)
REFERENCES table2 (t2_id_col) MATCH SIMPLE
ON UPDATE RESTRICT ON DELETE RESTRICT
);
What is that marked line above? It seems like the foreign key col rather than specifying int/int8 it is specifying a custom name t2_id
?
Whereas in table2
pk column which is being referenced above is of type serial
and is labeled t2_id_col
.
Is that some exotic syntax? Or something related to pgAdmin?