Add Constraints

Use alter table to add a constraint to an existing column.

For example, to add a constraint to the titles table that does not allow an advance in excess of 10,000:
alter table titles
add constraint advance_chk 
check (advance < 10000)

If a user attempts to insert a value greater than 10,000 into the titles table, SAP ASE produces an error message similar to this:

Msg 548, Level 16, State 1:
Line 1:Check constraint violation occurred,
dbname = ‘pubs2’,table name= ‘titles’,
constraint name = ‘advance_chk’.
Command has been aborted.

Adding a constraint does not affect the existing data. Also, if you add a new column with a default value and specify a constraint on that column, the default value is not validated against the constraint.

Related concepts
Drop Constraints