It is not possible to create a declarative constraint for this kind of thing. Of course, you could create a trigger to the INSERT level that would automatically fill the key based on the sequence (ignoring any value that was provided if you were concerned about special inserts that do not use the sequence).
If you are in a situation where you need to increase the sequence, because someone ad hoc inserts created lines with keys that exceed the current value of the sequence, your two options:
- Create a loop that calls nextval several times
- ALTER , INCREMENT BY , , nextval , ALTER - . , . , - reset .