Altering the Next Serial Value in a Typed Table
You can set the initial serial number or modify the next serial number for a ROW-type field with the MODIFY clause of the ALTER TABLE statement. (You cannot set the initial number for a serial field when you create a ROW data type.)
Suppose you have ROW types parent, child1, child2,
and child3.
CREATE ROW TYPE parent (a int); CREATE ROW TYPE child1 (s serial) UNDER parent; CREATE ROW TYPE child2 (b float, s8 serial8) UNDER child1; CREATE ROW TYPE child3 (d int) UNDER child2;
You then create corresponding typed tables:
CREATE TABLE OF TYPE parent; CREATE TABLE OF TYPE child1 UNDER parent; CREATE TABLE OF TYPE child2 UNDER child1; CREATE TABLE OF TYPE child3 UNDER child2;
To change the next SERIAL and SERIAL8 numbers to 75, you can issue
the following statement:
ALTER TABLE child3 MODIFY (s serial(75), s8 serial8(75));
When the ALTER TABLE statement executes, the database server updates corresponding serial columns in the child1, child2, and child3 tables.