This content has been marked as final. Show 6 replies
Use alter table to add column
alter table tableName add(columnName NUMBER);
Then create sequence
CREATE SEQUENCE SEQ_ID
START WITH 1
INCREMENT BY 1
and after it use UPDATE statement to insert values in column like this
UPDATE tableName SET columnName=seq_test_id.NEXTVAL
How many records in this table?
What's your Oracle version?
I hope you didn't try the update statement posted by first reply. It will not give you the result.
Start read some Oracle document to get yourself familiar with triggers and sequence.
Oracle version is 10g.
Thanks for the heads up. I have not tried anything yet. I'm still pretty much in the dark. I do know how to alter the table to add the id column but my knowledge ends at that point.
Did you try the process mentioned by HKaswan ? If so what was the problem. If not try it.
Oracle version is 10g.Again, don't use HKaswan's UPDATE statement, it's wrong.
Thanks for the heads up. I have not tried anything
yet. I'm still pretty much in the dark. I do know
how to alter the table to add the id column but my
knowledge ends at that point.
Check this old thread, it has a sample trigger code for auto increment
Auto Increment Feature
And check Oracle Document,
HKaswan's does indeed work IF you want to retroactively add values into an ID column you just added to an existing table.
You need to add a trigger for any new rows to continue grabbing the next sequence value.