You would need to add a column
ALTER TABLE userlog
ADD( user_id number );
create a sequence
CREATE SEQUENCE user_id_seq
START WITH 1
INCREMENT BY 1
CACHE 20;
Update the data in the table
UPDATE userlog
SET user_id = user_id_seq.nextval
Assuming that you want user_id
to be the primary key, you would then add the primary key constraint
ALTER TABLE userlog
ADD CONSTRAINT pk_user_id PRIMARY KEY( user_id );
If you want to use the sequence to automatically add the user_id
when you do an INSERT
(the other option would be to specifically reference user_id_seq.nextval
in your INSERT
statements, you would also need a trigger
CREATE OR REPLACE TRIGGER trg_userlog_user_id
BEFORE INSERT ON userlog
FOR EACH ROW
BEGIN
:new.user_id := user_id_seq.nextval;
END;
SAMPLE PPPPPPPPPPPPPPPP
ALTER TABLE TEST_EMAIL
ADD( NEWID number );
CREATE SEQUENCE NEWID_seq
START WITH 1
INCREMENT BY 1
CACHE 20;
UPDATE TEST_EMAIL
SET NEWID = NEWID_seq.nextval