creating foreign key constraint on a table

  • I'm trying to create a foreign key constraint referencing a particular table, but the ALTER TABLE statement never finishes (hangs) when run in Query Analyzer (I've let it run for 15 minutes with no luck). The table being referenced (term) has about 300 rows & it being queried frequently, but I've never seen a constraint take so long to be created. I can't bring down other applications that are querying the referenced table, since it is a production system. When I run the same SQL on a server with no database activity, it completes immediately. I'm trying to run something like this:

    ALTER TABLE triton_atm ADD CONSTRAINT fk_triton_atm_2

    FOREIGN KEY (id) REFERENCES term (id)

    Any ideas?

    Thanks,

    Ganesh

  • Have you looked at the server's Management -> Process Info display to see if the process that you're doing the ALTER TABLE with is locked, and if so, by what?

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply