Subject | Re: [firebird-support] Re: Rename Primary Key Foreign Key or Index |
---|---|
Author | Celyo |
Post date | 2003-10-03T13:32:03Z |
I knew how to find the name of the index but my problem is that I cannot
pass it as a parameter for a
DROP INDEX :Par statement.
:(
May be I'm missing something general so I'll try to explain my main problem
if there is a different solution.
I have a table called Packages with ... let's say 3 fields
Field1 NUMERIC(18,0),
Field2 INTEGER,
Field3 NUMERIC(18,0)
and I have a Primary Key on Field1.
I want to change the Primary Key to be on Field3.
The problem is that I don't know the name of the key!!!
I know I can see it using either a sql script or any db management utility
but my script has to work on databases with PK with different names and
should be done ONLY using sql script
So as far as I can tell I have to find a way to change the definition of the
PK in the system tables or find a way to drop it and create the new one
Iliya
pass it as a parameter for a
DROP INDEX :Par statement.
:(
May be I'm missing something general so I'll try to explain my main problem
if there is a different solution.
I have a table called Packages with ... let's say 3 fields
Field1 NUMERIC(18,0),
Field2 INTEGER,
Field3 NUMERIC(18,0)
and I have a Primary Key on Field1.
I want to change the Primary Key to be on Field3.
The problem is that I don't know the name of the key!!!
I know I can see it using either a sql script or any db management utility
but my script has to work on databases with PK with different names and
should be done ONLY using sql script
So as far as I can tell I have to find a way to change the definition of the
PK in the system tables or find a way to drop it and create the new one
Iliya
----- Original Message -----
From: "Svein Erling" <svein.erling.tysvaer@...>
To: <firebird-support@yahoogroups.com>
Sent: Friday, October 03, 2003 3:58 PM
Subject: [firebird-support] Re: Rename Primary Key Foreign Key or Index
> Well, Iliya, you can find its name by issuing something like
>
> select i.rdb$index_name
> from rdb$indices i
> where i.rdb$relation_name = <name of table>
> and exists (select * from rdb$index_segments s
> where i.rdb$index_name = s.rdb$index_name
> and s.rdb$field_name = <field names>)
> and exists (select * from rdb$index_segments s
> where i.rdb$index_name = s.rdb$index_name
> and s.rdb$field_name = <field names>)
> ... file://repeat as many times as number of fields in the index
> and not exists (select * from rdb$index_segments s
> where i.rdb$index_name = s.rdb$index_name
> and s.rdb$field_name NOT IN (<list of field names>))
>
> I have never tried doing anything like this, but it should not be too
> difficult unless you have several indexes covering the same columns
> (and if so, just add criteria for s.field_position).
>
> HTH,
> Set
>
>
>
> To unsubscribe from this group, send an email to:
> firebird-support-unsubscribe@yahoogroups.com
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
>