Subject | Add and populate a primary key |
---|---|
Author | marc_guillot |
Post date | 2008-06-10T08:42:26Z |
Hello.
I have imported data from an old database, with no primary keys in
most tables. I want to add and populate a primary key to them, but I
don't know how to do it.
I remember there is some kind of virtual column to identify a row in a
table with no primary key, but I don't remember his name and I can't
find it.
How can I do something like that (what is then name of XXX field name) ? :
-----
alter table OLD_DATA add ID integer;
-----
ID = 1;
for select XXX
from OLD_DATA
into :XXX do begin
update OLD_DATA set ID = :ID where XXX = :XXX;
ID = ID + 1;
end
----
alter table OLD_DATA add constraint PK_OLD_DATA primary key (ID)
---
Thanks.
I have imported data from an old database, with no primary keys in
most tables. I want to add and populate a primary key to them, but I
don't know how to do it.
I remember there is some kind of virtual column to identify a row in a
table with no primary key, but I don't remember his name and I can't
find it.
How can I do something like that (what is then name of XXX field name) ? :
-----
alter table OLD_DATA add ID integer;
-----
ID = 1;
for select XXX
from OLD_DATA
into :XXX do begin
update OLD_DATA set ID = :ID where XXX = :XXX;
ID = ID + 1;
end
----
alter table OLD_DATA add constraint PK_OLD_DATA primary key (ID)
---
Thanks.