Subject | Re: [firebird-support] Firebird record number |
---|---|
Author | geo.mastique@laposte.net |
Post date | 2006-11-27T14:32:36Z |
so easy with generator... thanks for your help !
but for another kind of use, how to get the rownumber of a table in a
query ?
Martijn Tonies a écrit :
but for another kind of use, how to get the rownumber of a table in a
query ?
Martijn Tonies a écrit :
> 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 <http://www.upscene.com>
> My thoughts:
> http://blog.upscene.com/martijn/ <http://blog.upscene.com/martijn/>
> Database development questions? Check the forum!
> http://www.databasedevelopmentforum.com
> <http://www.databasedevelopmentforum.com>
>
>