top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Oracle: How can I generate primary key values for my table?

0 votes
44 views
Oracle: How can I generate primary key values for my table?
posted Jun 17, 2015 by Vidhya Sagar

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

1 Answer

+1 vote
 
Best answer

Create your table with a NOT NULL column (say SEQNO). This column can now be populated
with unique values:
SQL> UPDATE table_name SET seqno = ROWNUM;

or use a sequences generator:

SQL> CREATE SEQUENCE sequence_name START WITH 1 INCREMENT BY 1;
SQL> UPDATE table_name SET seqno = sequence_name.NEXTVAL;

Finally, create a unique index on this column.

answer Jun 19, 2015 by Arun Gowda
Similar Questions
+2 votes

I have created one table where I want to add combination of multiple column as primary key.

Can someone please help me to know how to do this?

+1 vote

In my table I have three unique column this can be referred by other table.
Which key I have to use for this.

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...