I developed application in Oracle 12c there Id is autoincremented but same application i want to run in oracle11g how to do it. any plugin to autoincrement the Id column
Asked
Active
Viewed 37 times
0
-
if it's all PL/SQL you can use a SEQUENCE and just use NEXTVAL to populate the field. – BigMike Jan 16 '19 at 13:09
-
Share the code that's giving the issue – sechanakira Jan 16 '19 at 13:14
1 Answers
1
There's no really easy way, you can probably make it automatic with triggers, but I fear it will just make things worse.
Let's say you have a table TEST
CREATE TABLE TEST (
ID_TEST NUMBER,
VAL_TEST VARCHAR2(10)
);
If you want to automatically set ID_TEST you can:
CREATE SEQUENCE SEQ_TEST_ID START WITH 1 NOCACHE; -- to have single increments
then change your inserts adding the ID_TEST column.
INSERT INTO TEST (ID_TEST, VAL_TEST) values (SEQ_TEST_ID.NEXTVAL, 'foo');
INSERT INTO TEST (ID_TEST, VAL_TEST) values (SEQ_TEST_ID.NEXTVAL, 'foo');
Sure you still have to modify your insert statements, so depending on the number of those this may be or may be not a fast approach.

BigMike
- 6,683
- 1
- 23
- 24
-
1"Making it automatic with triggers" is the standard way to accomplish this in versions of Oracle prior to 12c. – Bob Jarvis - Слава Україні Jan 16 '19 at 13:33