RE: Row Number

Bert Scalzo <[email protected]> Mon, 14 Jan 2013 21:13:27 +0000
Newsgroups gmane.comp.db.oracle.toad.free
Message-ID <228D4BD15697E04CAF6CD482362F2ACE1394912A@ALVMBXW02.prod.quest.corp>
>>>> I want to use the row number as a unique id field.

Bad database design. Look at Codd's rules - do not use physical address for anything. Here's why. You code app based on this. I then reorg the table at some point. And viola - now the row id's are different but you have the old values in your database. Do not go here!

From: [email protected] [mailto:[email protected]] On Behalf Of Joseph Charpak
Sent: Monday, January 14, 2013 3:11 PM
To: [email protected]
Subject: Re: [toad] Row Number


On 01/14/2013 04:03 PM, joefootball_91 wrote:


Is there a way to add a row number to a query? I want to use the row number as a unique id field. Is there a function similar to the ROW_NUMBER() that's available?

I have a table named CUSTOMERS with fields titled FirstName and LastName. I want each row to have a unique number (the first row 1, the second row 2, third row 3, etc.) similar to the table below.

ID FirstName LastName
1 xxxxx xxxxxx
2 xxxxx xxxxxx
3 xxxxx xxxxxx
4 xxxxx xxxxxx
N xxxxx xxxxxx
Research the rank() function. There's also rownum but that wont do what you want (it's borderline useless)