I have a Conceptual Data Model in Power Designer, and I need to have a SQL script that add and manage surrogate key on my dimensions tables, but I don't know if it's a good way to do it.
Is there another way to add surrogate key and to increment them automatically ?
I know that I can use Transformations option or Custom Check, but i don't know what is the best solution.
To finally give an answer, according to Pascals' comment
I've created a sequence :
create sequence SK_SEQUENCES
increment by 1
start with 1
nomaxvalue
minvalue 1
nocycle
order
keep;
and add a trigger to the Surrogate Key
create or replace trigger incrsk
before insert on schema.table
for each row
begin
:new.SKTEST := SK_SEQUENCES.NEXTVAL;
end;
/
So every time that I add a row to the table, the SK is incremented by 1.