0

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

Andrew Spencer
  • 15,164
  • 4
  • 29
  • 48

1 Answers1

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