Re: dropping a primary key

From: Graeme Sargent <graeme_at_pyramid.com>
Date: 1995/04/20
Message-ID: <3n5ro7$dc1_at_sword.eng.pyramid.com>#1/1


Murray Kaiser (ae873_at_cfn.cs.dal.ca) wrote:
: Nagaraj Rekha (nr1_at_Ra.MsState.Edu) wrote:
 

: : Hi netters!!
 

: : I have been trying to drop aprimary key and a foriegn key from a table with
: : out success. I have been using the Disable command.
: : I would appreciate it if any one could tell me where I am going wrong and
: : thr right procedure to do it.

: : Rekha Nagaraj
: : E-mail: rekha_at_erc.msstate.edu

: --
: Here's my guess to drop a primary key:
 

: 1) Get the primary key constraint name for the table
 

: SELECT CONSTRAINT_NAME FROM USER_CONSTRAINTS
: WHERE TABLE_NAME = 'the table with the primary key';
 

: 2) Get the referencing tables and their foreign key constraint names for
: this primary key constraint
 

: SELECT CONSTRAINT_NAME, TABLE_NAME FROM USER_CONSTRAINTS
: WHERE R_CONSTRAINT_NAME = 'constraint name above';
 

: 3) Alter each of the referencing table dropping the foreign key
: constraint to the primary key table
 

: ALTER TABLE for each table name returned above DROP CONSTRAINT
: corresponding foreign key constraint name above;
 

: 4) Alter the primary key table dropping the primary key constraint
 

: ALTER TABLE table name with the primary key DROP CONSTRAINT primary key
: constraint name;

Whew!

Does this mean that "ALTER TABLE ... DROP PRIMARY KEY CASCADE;" doesn't work for some reason???

--
graeme
--
Disclaimer:	The author's opinions are his own, and not necessarily
		those of Pyramid Technology Ltd. or Pyramid Technology Inc.
---------------------------------------------------------------------------
      -m------- Graeme Sargent                 Voice: +44 (0)252 373035
    ---mmm----- Senior Database Consultant     Fax  : +44 (0)252 373135
  -----mmmmm--- Pyramid Technology Ltd.        Telex: Tell who???
-------mmmmmmm- Farnborough, Hants  GU14 7PL   Email: graeme_at_pyra.co.uk
---------------------------------------------------------------------------
    We have the technology.  The tricky bit is learning how to use it.
Received on Thu Apr 20 1995 - 00:00:00 CEST

Original text of this message