Question

I have two tables that already have data in them and i would like to create reference via postgressql OR SQL shell. The reference should be like this:

[IMG]http://i.imgur.com/SMUEo4r.png[/IMG]

Can anyone tell me how to do that?

Was it helpful?

Solution

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:

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top