I want to create a user defined data type, let's call it ‘MyPosInt’ which can take only positive integers within 1 to 100 as its value in DB2.
Now I know, I can create a user defined datatype using 'CREATE DATATYPE' query, but how do I impose this constraint.
Check out this:
CREATE TYPE MyPosInt AS INTEGER WITH WEAK TYPE RULES
CHECK(VALUE > 0 AND VALUE <= 100)
You will find more details in the documentation