Subject Re: [firebird-support] Trying to change a PK field name
Author Helen Borrie
At 12:42 PM 13/03/2006, you wrote:
>Hi,
>
>Can any one help a problem I am having?
>
>I created a table with a field that has lower case characters. When I
>try to use the field name in an UPDATE Firebird kicks back the field
>name as Upper case and says it can not find the field in the table. I
>have tried to change the field to upper case, but errors because the
>field is the PK.
>
>I have tryed to drop the field, alter the field, drop the index, drop
>pthe constaint, and drop the table.
>
>All data has been deleted from the table.

Well, it's true that you can't drop a column that has a PK constraint
on it. But it's also true that you can't change the identifier of
any column. You have to create a new NOT NULL column with the new
name and the same attributes as the PK column. Commit it, and then
pump the data into it.

Next, you drop the PK constraint. (This will mean dropping any FK
constraints that depend on it, first.) And commit.

Then you can drop the column. And commit.

Next, recreate the column, using double-quotes around the identifier
if you want it to be case-sensitive. (SQL identifiers are not
case-sensitive, by default.). And commit.

Then pump the data from the temp column into this recreated
column. And commit.

Now add the primary key constraint. And commit.

Now you can drop the temp column whenever you're ready; and recreate
your foreign keys, whenever you're ready.

./heLen





>Any ideas?
>
>Ed Perkins
>
>
>
>
>
>
>
>
>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>Visit http://firebird.sourceforge.net and click the Resources item
>on the main (top) menu. Try Knowledgebase and FAQ links !
>
>Also search the knowledgebases at http://www.ibphoenix.com
>
>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>Yahoo! Groups Links
>
>
>
>