7.4 - TODO : alter table drop foreign key
7.4 - TODO : alter table drop foreign key
От:
"Dan Langille" <dan@langille.org>
Дата:
We support "alter table add foreign key". How about supporting "alter table drop foreign key"? - he said as he went to drop a foreign key -- Dan Langille : http://www.langille.org/
Re: 7.4 - TODO : alter table drop foreign key
От:
Stephan Szabo <sszabo@megazone23.bigpanda.com>
Дата:
On Thu, 5 Dec 2002, Dan Langille wrote: > We support "alter table add foreign key". How about supporting > "alter table drop foreign key"? > > - he said as he went to drop a foreign key It seems to work for me on my 7.3b2 system with alter table
Re: 7.4 - TODO : alter table drop foreign key
От:
"Dan Langille" <dan@langille.org>
Дата:
On 5 Dec 2002 at 8:20, Stephan Szabo wrote: > > On Thu, 5 Dec 2002, Dan Langille wrote: > > > We support "alter table add foreign key". How about supporting > > "alter table drop foreign key"? > > > > - he said as he went to drop a foreign key > > It seems to work for me on my 7.3b2 system with > alter table
Re: 7.4 - TODO : alter table drop foreign key
От:
"Dan Langille" <dan@langille.org>
Дата:
On 5 Dec 2002 at 8:20, Stephan Szabo wrote: > > On Thu, 5 Dec 2002, Dan Langille wrote: > > > We support "alter table add foreign key". How about supporting > > "alter table drop foreign key"? > > > > - he said as he went to drop a foreign key > > It seems to work for me on my 7.3b2 system with > alter table
Re: 7.4 - TODO : alter table drop foreign key
От:
Stephan Szabo <sszabo@megazone23.bigpanda.com>
Дата:
On Thu, 5 Dec 2002, Dan Langille wrote: > On 5 Dec 2002 at 8:20, Stephan Szabo wrote: > > > > > On Thu, 5 Dec 2002, Dan Langille wrote: > > > > > We support "alter table add foreign key". How about supporting > > > "alter table drop foreign key"? > > > > > > - he said as he went to drop a foreign key > > > > It seems to work for me on my 7.3b2 system with > > alter table
Re: 7.4 - TODO : alter table drop foreign key
От:
"Dan Langille" <dan@langille.org>
Дата:
On 5 Dec 2002 at 8:44, Stephan Szabo wrote: > On Thu, 5 Dec 2002, Dan Langille wrote: > > > On 5 Dec 2002 at 8:20, Stephan Szabo wrote: > > > > > > > > On Thu, 5 Dec 2002, Dan Langille wrote: > > > > > > > We support "alter table add foreign key". How about supporting > > > > "alter table drop foreign key"? > > > > > > > > - he said as he went to drop a foreign key > > > > > > It seems to work for me on my 7.3b2 system with > > > alter table
Re: 7.4 - TODO : alter table drop foreign key
От:
"Dan Langille" <dan@langille.org>
Дата:
On 5 Dec 2002 at 11:47, Dan Langille wrote: > On 5 Dec 2002 at 8:44, Stephan Szabo wrote: > > > On Thu, 5 Dec 2002, Dan Langille wrote: > > > > > On 5 Dec 2002 at 8:20, Stephan Szabo wrote: > > > > > > > > > > > On Thu, 5 Dec 2002, Dan Langille wrote: > > > > > > > > > We support "alter table add foreign key". How about supporting > > > > > "alter table drop foreign key"? > > > > > > > > > > - he said as he went to drop a foreign key > > > > > > > > It seems to work for me on my 7.3b2 system with > > > > alter table
Re: 7.4 - TODO : alter table drop foreign key
От:
Stephan Szabo <sszabo@megazone23.bigpanda.com>
Дата:
On Thu, 5 Dec 2002, Dan Langille wrote: > Found the solution: > > drop trigger "RI_ConstraintTrigger_4278488" on watch_list_staging; Actually there are three triggers for the constraint. You may have dangling triggers on the other table of the constraint. It's one on the table the constraint's defined on and two on the referenced table. > Given that the FK in question did not have a name to start with, I > concede that it would be difficult to code DROP FOREIGN KEY. > > What about supporting ALTER TABLE
Re: 7.4 - TODO : alter table drop foreign key
От:
"Dan Langille" <dan@langille.org>
Дата:
On 5 Dec 2002 at 9:02, Stephan Szabo wrote: > On Thu, 5 Dec 2002, Dan Langille wrote: > > > Found the solution: > > > > drop trigger "RI_ConstraintTrigger_4278488" on watch_list_staging; > > Actually there are three triggers for the constraint. You may have > dangling triggers on the other table of the constraint. It's one on the > table the constraint's defined on and two on the referenced table. > > > Given that the FK in question did not have a name to start with, I > > concede that it would be difficult to code DROP FOREIGN KEY. > > > > What about supporting ALTER TABLE
Re: 7.4 - TODO : alter table drop foreign key
От:
Stephan Szabo <sszabo@megazone23.bigpanda.com>
Дата:
On Thu, 5 Dec 2002, Dan Langille wrote: > On 5 Dec 2002 at 9:02, Stephan Szabo wrote: > > > On Thu, 5 Dec 2002, Dan Langille wrote: > > > > > Found the solution: > > > > > > drop trigger "RI_ConstraintTrigger_4278488" on watch_list_staging; > > > > Actually there are three triggers for the constraint. You may have > > dangling triggers on the other table of the constraint. It's one on the > > table the constraint's defined on and two on the referenced table. > > > > > Given that the FK in question did not have a name to start with, I > > > concede that it would be difficult to code DROP FOREIGN KEY. > > > > > > What about supporting ALTER TABLE
Re: 7.4 - TODO : alter table drop foreign key
От:
"Dan Langille" <dan@langille.org>
Дата:
On 5 Dec 2002 at 9:31, Stephan Szabo wrote: > When we talk about ALTER TABLE ADD FOREIGN KEY we're being imprecise, so > I think that might be why we're talking past each other here. > > Technically the syntax in question is: > ALTER TABLE
Re: 7.4 - TODO : alter table drop foreign key
От:
Stephan Szabo <sszabo@megazone23.bigpanda.com>
Дата:
On Thu, 5 Dec 2002, Dan Langille wrote: > On 5 Dec 2002 at 9:31, Stephan Szabo wrote: > > > When we talk about ALTER TABLE ADD FOREIGN KEY we're being imprecise, so > > I think that might be why we're talking past each other here. > > > > Technically the syntax in question is: > > ALTER TABLE
Re: 7.4 - TODO : alter table drop foreign key
От:
"Dan Langille" <dan@langille.org>
Дата:
On 5 Dec 2002 at 9:51, Stephan Szabo wrote: > On Thu, 5 Dec 2002, Dan Langille wrote: > > > On 5 Dec 2002 at 9:31, Stephan Szabo wrote: > > > > > When we talk about ALTER TABLE ADD FOREIGN KEY we're being imprecise, so > > > I think that might be why we're talking past each other here. > > > > > > Technically the syntax in question is: > > > ALTER TABLE
Re: 7.4 - TODO : alter table drop foreign key
От:
Rod Taylor <rbt@rbt.ca>
Дата:
> Thanks. I guess I should rename my thread to 7.4 - TODO : allow > constraint names when using the "ALTER TABLE
Re: 7.4 - TODO : alter table drop foreign key
От:
Fernando Nasser <fnasser@redhat.com>
Дата:
Dan Langille wrote:> On 5 Dec 2002 at 11:47, Dan Langille wrote: > >>Primary key: watch_list_staging_pkey >>Check constraints: "watch_list_stag_from_watch_list" >>((from_watch_list = 't'::bool) OR (from_watch_list = 'f'::bool)) >> "watch_list_stagin_from_pkg_info" ((from_pkg_info >>= 't'::bool) OR (from_pkg_info = 'f'::bool)) >>Triggers: RI_ConstraintTrigger_4278482, >> RI_ConstraintTrigger_4278488 >> >>No mention of FK constraints. > > > Found the solution: > > drop trigger "RI_ConstraintTrigger_4278488" on watch_list_staging; > You should now go to the table this RI constraint was referring to and delete the two triggers in there as well. They will still be checking for deletions and updates. Look for something like RI_ConstraintTrigger_4278490 RI_ConstraintTrigger_4278492 and with the associated procedure RI_FKey_noaction_del and RI_FKey_noaction_upd BTW, the rhdb-admin program can drop the constraints for you, even the unnamed ones on backends 7.2 up. You can download it from: http://sources.redhat.com/rhdb Of course, now that you broke the set of triggers for this FK constraint you'll still need to drop the other ones by hand. But the tool at least will show you the column and table involved so it will be easier to identify the two you have to get rid of. Regards, Fernando -- Fernando Nasser Red Hat - Toronto E-Mail: fnasser@redhat.com 2323 Yonge Street, Suite #300 Toronto, Ontario M4P 2C9
Re: 7.4 - TODO : alter table drop foreign key
От:
"Dan Langille" <dan@langille.org>
Дата:
On 5 Dec 2002 at 14:04, Rod Taylor wrote: > > Thanks. I guess I should rename my thread to 7.4 - TODO : allow > > constraint names when using the "ALTER TABLE
Re: 7.4 - TODO : alter table drop foreign key
От:
"Dan Langille" <dan@langille.org>
Дата:
On 5 Dec 2002 at 14:17, Fernando Nasser wrote: > Dan Langille wrote:> On 5 Dec 2002 at 11:47, Dan Langille wrote: > > > > drop trigger "RI_ConstraintTrigger_4278488" on watch_list_staging; > > > > You should now go to the table this RI constraint was referring to and delete > the two triggers in there as well. They will still be checking for deletions > and updates. Look for something like > RI_ConstraintTrigger_4278490 > RI_ConstraintTrigger_4278492 > and with the associated procedure RI_FKey_noaction_del and RI_FKey_noaction_upd Oh thank you! I didn't know about those. FWIW, I've just documented this exercise at http://www.freebsddiary.org/postgresql-dropping- constraints.php so corrections are most welcome. > BTW, the rhdb-admin program can drop the constraints for you, even the unnamed > ones on backends 7.2 up. You can download it from: > > http://sources.redhat.com/rhdb Thanks. I hope to check that out one day. > Of course, now that you broke the set of triggers for this FK constraint you'll > still need to drop the other ones by hand. But the tool at least will show you > the column and table involved so it will be easier to identify the two you have > to get rid of. I did the identification by hand and fixed it up that way. Hopefully there's nothing else in there I've done wrong. -- Dan Langille : http://www.langille.org/
Re: 7.4 - TODO : alter table drop foreign key
От:
"Christopher Kings-Lynne" <chriskl@familyhealth.com.au>
Дата:
> > > Thanks. I guess I should rename my thread to 7.4 - TODO : allow > > > constraint names when using the "ALTER TABLE
Re: 7.4 - TODO : alter table drop foreign key
От:
"Dan Langille" <dan@langille.org>
Дата:
On 5 Dec 2002 at 11:52, Christopher Kings-Lynne wrote: > > > > Thanks. I guess I should rename my thread to 7.4 - TODO : allow > > > > constraint names when using the "ALTER TABLE
Re: 7.4 - TODO : alter table drop foreign key
От:
"Christopher Kings-Lynne" <chriskl@familyhealth.com.au>
Дата:
> > Isn't it identical? The CONSTRAINT is SQL standard optional clause > > for all commands that add constraints. > > Except that one is ADD CONSTRAINT, the other is an ADD FOREIGN KEY. > They are similar in nature but different overall. I think you're getting a little confused here, Dan. http://www3.us.postgresql.org/users-lounge/docs/7.3/postgres/sql-altertable. html There is only one command for adding constraints to a table. It has this syntax: ALTER TABLE [ ONLY ] table [ * ] ADD table_constraint The table_constraint clause is defined like this (basically): [CONSTRAINT blah] (PRIMARY KEY or UNIQUE or FOREIGN KEY) ... So, the CONSTRAINT blah clause allows you to specify a name for any of the 3 types of constraint: primary key, unique or foreign key. There's nothing special about foreign keys in this case. If you don't put in the CONSTRAINT blah clause, you get an automatically assigned constraint name. Chris
Re: 7.4 - TODO : alter table drop foreign key
От:
Rod Taylor <rbt@rbt.ca>
Дата:
On Thu, 2002-12-05 at 14:52, Christopher Kings-Lynne wrote: > > > > Thanks. I guess I should rename my thread to 7.4 - TODO : allow > > > > constraint names when using the "ALTER TABLE
Re: 7.4 - TODO : alter table drop foreign key
От:
"Dan Langille" <dan@langille.org>
Дата:
On 5 Dec 2002 at 12:09, Christopher Kings-Lynne wrote: > > > Isn't it identical? The CONSTRAINT is SQL standard optional > clause > > > for all commands that add constraints. > > > > Except that one is ADD CONSTRAINT, the other is an ADD FOREIGN KEY. > > They are similar in nature but different overall. > > I think you're getting a little confused here, Dan. > > http://www3.us.postgresql.org/users-lounge/docs/7.3/postgres/sql-altertable. > html > > There is only one command for adding constraints to a table. It has this > syntax: > > ALTER TABLE [ ONLY ] table [ * ] > ADD table_constraint > > The table_constraint clause is defined like this (basically): > > [CONSTRAINT blah] (PRIMARY KEY or UNIQUE or FOREIGN KEY) ... > > So, the CONSTRAINT blah clause allows you to specify a name for any of the 3 > types of constraint: primary key, unique or foreign key. There's nothing > special about foreign keys in this case. > > If you don't put in the CONSTRAINT blah clause, you get an automatically > assigned constraint name. Regardless of what is documented, the following is valid and works: ALTER TABLE slave ADD FOREIGN KEY (master_id) REFERENCES master (id) ON DELETE CASCADE; -- Dan Langille : http://www.langille.org/
Re: 7.4 - TODO : alter table drop foreign key
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"Dan Langille" writes: >> You can do that now. >> ALTER TABLE
Re: 7.4 - TODO : alter table drop foreign key
От:
"Dan Langille" <dan@langille.org>
Дата:
On 5 Dec 2002 at 15:36, Tom Lane wrote: > "Dan Langille" writes: > >> You can do that now. > >> ALTER TABLE