ALTER TABLE query

I

Ivan Debono

Hi all,

I have the following sql:

ALTER TABLE details_table ADD constraint FK_mastertable_detailstable
REFERENCES master_table (id)

Where id is the pimary key of the master table.

The problem is that it's not creating a relationship between the 2 tables.
Am I skipping something?

Thanks,
Ivan
 
G

Guest

Hi Ivan,

While I do not profess any expertise in DDE queries, I think you need to
give each relation a unique name and include Foreign key. Try the following:

ALTER TABLE details_table
ADD constraint RELATION1 FOREIGN KEY ([FK_mastertable_detailstable])
REFERENCES master_table ([id]);


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

:

Hi all,

I have the following sql:

ALTER TABLE details_table ADD constraint FK_mastertable_detailstable
REFERENCES master_table (id)

Where id is the pimary key of the master table.

The problem is that it's not creating a relationship between the 2 tables.
Am I skipping something?

Thanks,
Ivan
 
G

Guest

Oops....meant to say "DDL" (Data Definition Language) queries, not DDE, which
is short for Dynamic Data Exchange.
____________________________________________

:

Hi Ivan,

While I do not profess any expertise in DDE queries, I think you need to
give each relation a unique name and include Foreign key. Try the following:

ALTER TABLE details_table
ADD constraint RELATION1 FOREIGN KEY ([FK_mastertable_detailstable])
REFERENCES master_table ([id]);


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

:

Hi all,

I have the following sql:

ALTER TABLE details_table ADD constraint FK_mastertable_detailstable
REFERENCES master_table (id)

Where id is the pimary key of the master table.

The problem is that it's not creating a relationship between the 2 tables.
Am I skipping something?

Thanks,
Ivan
 
I

Ivan Debono

Tom Wickerath said:
Oops....meant to say "DDL" (Data Definition Language) queries, not DDE,
which
is short for Dynamic Data Exchange.
____________________________________________

:

Hi Ivan,

While I do not profess any expertise in DDE queries, I think you need to
give each relation a unique name and include Foreign key. Try the
following:

ALTER TABLE details_table
ADD constraint RELATION1 FOREIGN KEY ([FK_mastertable_detailstable])
REFERENCES master_table ([id]);


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

:

Hi all,

I have the following sql:

ALTER TABLE details_table ADD constraint FK_mastertable_detailstable
REFERENCES master_table (id)

Where id is the pimary key of the master table.

The problem is that it's not creating a relationship between the 2 tables.
Am I skipping something?

Thanks,
Ivan

Yep, that was the missing parentheses around the id :)

Ivan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top