I would like to define a column that auto-increment but it should be bigger than serial type but it should be less than the max serial8. So I want to define the column type as serial8. But i want to limit the incremental on 12 integers. I want to throw an error if the incremental reaches 12 integers. is there any way to do it in the ddl?
I would use a check constraint at the column level, something like
create table tablename (
col2 serial8 CHECK (col2 BETWEEN 0 AND 999999999999),
If the value is above the indicated value, the application will received a check constraint violation error ( probably -6nn error or so, just test and check).
You can handle it as a normal error in your application.