I want set some constraint to the serial type,it only produce even or odd numbers.
serial type produce only even or odd numbers in postgresql
2.3k Views Asked by yjfuk At
2
I want set some constraint to the serial type,it only produce even or odd numbers.
SERIAL
is a syntax sugar around creating and using sequences.So you could do it all manually and create a special type of sequence that suits your needs:
Or if you already have a table and a
SERIAL
column you could change the underlying sequence:The name of the underlying sequence could be retrieved by "describing" the table using psql: