Link to home
Start Free TrialLog in
Avatar of Maliki Hassani
Maliki HassaniFlag for United States of America

asked on

ORACLE 10g: Function - insert unique identifier using sequence

Experts,

I have a function that truncates a table and inserts new data.  The data that is being inserted doesn't have a unique ID nor does it have a field that is unique in records.  Therefore, I want to create a unique id for each row, which has to be numbers only.  Any ideas on how to accomplish this?

Example:
Colum1 (ID)
1
2
3
4
5
etc

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of Sean Stuber
Sean Stuber

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sean Stuber
Sean Stuber

also, if this is 12c,  you can associate a sequence with a column to create an "identity column" like you see in other databases.
Avatar of Maliki Hassani

ASKER

Great I will give this a try!
I used rownum and that that worked.  Do I need to have a sequence added and applied or just use rownum?
Let me rephrase that..  as for speed is it better to use sequence or row number?  Thanks
the difference will be very minor, but rownum should probably be minorly more efficient since it never has to update the data dictionary but a sequence with a large cache value will minimize that.

Best way to verify is to simply run both on your system and test results.