Thursday, 15 May 2014

mysql - I get an error in PostgreSql: number of referencing and referenced columns for foreign key disagree -



mysql - I get an error in PostgreSql: number of referencing and referenced columns for foreign key disagree -

i'm creating table, error:

- number of referencing , referenced columns foreign key disagree.

i don't know how solve it. think may problem declaring 3 foreign keys, but, i'm not sure it.

what problem?

thanks!

class="lang-sql prettyprint-override">create table trasllat ( info date, codi_empleat integer, nom_agencia varchar(30), data_fi date, primary key (data, codi_empleat), foreign key (data) references info on delete cascade, foreign key (codi_empleat) references empleat on delete cascade foreign key (nom_agencia) references agencia on delete cascade );

that's because not specifying specific column name of table should reference to. foreign key declaration should below. notice part, references empleat(column_name) says column codi_empleat references empleat tables column_name column.

foreign key (data) references trasllat(data) on delete cascade, foreign key (codi_empleat) references empleat(column_name) on delete cascade foreign key (nom_agencia) references agencia(column_name) on delete cascade

check postgres documentation more info on same.

mysql postgresql foreign-keys

No comments:

Post a Comment