top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

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

0 votes
87 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 LinkedIn 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.

...