I have a table in oracle of which all rows of a column has to be updated with a starting value of 500 and incrementing by 1.
CREATE table1 AS SELECT object_name, object_type FROM user_objects; BEGIN INSERT INTO table1(col1, col2) VALUES('value1','value2'); UPDATE table1 SET col1 = 'another value' WHERE col2 IS NULL; DELETE FROM table1 WHERE col1 = col2; COMMIT; END; / DROP table1; CREATE table1 AS SELECT object_name, object_type FROM user_objects; DECLARE x VARCHAR2(128) := 'value1'; y NUMBER := 10; BEGIN INSERT INTO table1(col1, col2) VALUES(x, x); UPDATE table1 SET col1 = x WHERE col3 The values of the cursor attributes always refer to the most recently executed SQL statement, wherever that statement is.
It might be in a different scope (for example, in a sub-block).
INSERT INTO emp VALUES emp_rec; -- The fields of a %ROWTYPE can completely replace the table columns.
UPDATE emp SET ROW = emp_rec WHERE eno = 100; END; / statements in SQL) and access individual fields or entire rows from the result set.
I know how to create a sequence and trigger to add an auto-incrementing ID for new rows added to the table, but is it possible to write a PL/SQL statement to add unique IDs to all the rows that are already in the table?