Subject Re: [firebird-support] Firebird record number
Author Martijn Tonies
Hello Julien,


> i want to add a field in a table that contains the record number of the
> line.
> this field will be the key field because my data are so bad without
> unique key.
> so the idea is to create a field then update the field with rownumber
> for each row.

Well, there are no rownumbers, but you can easily do this.

alter table <your table>
add column with not null and so on.

Next, create a "generator":

create generator g_mytable;

update yourtable
set newcolumn = gen_id(g_mytable, 1);

And you're done with.

Next, create your primary key on that column.


Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle &
MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com