alter table statusi
add constraint fk_darbinieki_statusi
foreign key (id_darbinieks) references darbinieki (id_darbinieks);
Note that I used unquoted identifiers which are case insensitive.
Given your screenshot it might be that you created quoted identifiers using double quotes which are case sensitive. "ID_statusi"
is a different name than ID_statusi
. So maybe you need to use double quotes when running the above statement. In general, using double quotes for identifiers is not such a good idea. It creates more trouble than it's worth.
More details in the manual:
- defining foreign keys:
http://www.postgresql.org/docs/current/static/ddl-constraints.html#DDL-CONSTRAINTS-FK - Rules for identifiers:
http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS - ALTER TABLE:
http://www.postgresql.org/docs/current/static/sql-altertable.html