I want to create a sql for a sequence that will dynamically set the starting value.
The following sql runs into an error.
CREATE SEQUENCE id_seq START WITH (SELECT MAX(identificationnumber)+1 FROM newsletter_status);
Could not execute 'CREATE ...
sql used in the creation:
CREATE TABLE autoincremet_test(
identificationnumber BIGINT NOT NULL PRIMARY KEY,
desc varchar(10)
);
I want identificationnumber to be autoincremented, so it is equivalent ot this DML:
CREATE TABLE autoincre...
-- Creates a autoincrementing sequence
CREATE SEQUENCE identificationnumber_sequence START WITH <your_starting_value>;
-- Creates a trigger that uses the sequence to update the newly created row before insertion
CREATE TRIGGER identificationnumber_t...
The "Restart with" looks like what I am searching for.The Idea behind the dynamic is that we have a DB migration in plan. We would have an very limited time span for it and we nedd to be fast. The starting value for the sequence could change with tim...
From the documentation I read that RESET BY will be executed every time the DB restarts. This is not desired. The Sequence should be created once and then do not change. It is possible that some ids would be deleted in the future and in combination w...
Hi,I could manage to solve the exact same problem with the following sql:CREATE SEQUENCE identificationnumber_sequence START WITH <your_startign_value>;CREATE TRIGGER identificationnumber_trigger
BEFORE INSERT ON <table>
REFERENCING NEW ROW N_ROW
FOR...