create the relationship without referential integrity using the microsoft jet sql

Y

Yor

Hi, I want to create a relationship between tables A and B without
referential integrity using the "Microsoft Jet SQL" to create the structure
with a script. When I create with the following sentences:
ALTER TABLE [TablaB] ADD
CONSTRAINT [RL_TablaB_IDA] ([IDA]) REFERENCES [TablaA] ([ID]);

It create the relationship with the referential integrity.

How Can I create the relationship without referential integrity using the
Microsoft Jet SQL?

Thanks
 
M

Michel Walsh

Hi,

Almost there.

You can use, in the immediate debug window, or elsewhere using ADO (although
if I didn't check using DAO neither using the query designer ):


CurrentProject.Connection.Execute "ALTER TABLE table1 ADD CONSTRAINT
constraintName FOREIGN KEY NO INDEX (listOfFields) REFERENCES otherTable
(itsListOfFields) ON UPDATE CASCADE ON DELETE CASCADE "


where NO INDEX, ON UPDATE CASCADE and ON DELETE CASCADE are optional and can
be omitted. If you specify no index, no index would be created on that list
of fields (cases such as gender, with only few values repeated a large
number of time, so an index would be useless) and you can use NO ACTION
instead of the CASCADE, which is the default behavior.



Hoping it may help,
Vanderghast, Access MVP
 

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