Complete the code to create a domain named 'positive_int' that only allows integers greater than zero.
CREATE DOMAIN positive_int AS INTEGER CHECK (VALUE [1] 0);
The domain 'positive_int' should only accept integers greater than zero, so the check condition uses > 0.
Complete the code to create a domain 'email_text' that only accepts text containing the '@' character.
CREATE DOMAIN email_text AS TEXT CHECK (POSITION('[1]' IN VALUE) > 0);
The '@' character is essential in email addresses, so the check ensures it appears in the text.
Fix the error in the domain creation that should restrict a phone number to exactly 10 digits.
CREATE DOMAIN phone_number AS TEXT CHECK (LENGTH(VALUE) [1] 10);
The phone number must have exactly 10 digits, so the length must be equal to 10.
Fill both blanks to create a domain 'rating' that accepts integers between 1 and 5 inclusive.
CREATE DOMAIN rating AS INTEGER CHECK (VALUE [1] 1 AND VALUE [2] 5);
The rating must be at least 1 (using >=) and at most 5 (using <=) to include both ends.
Fill all three blanks to create a domain 'zipcode' that accepts exactly 5 digits and only numeric characters.
CREATE DOMAIN zipcode AS TEXT CHECK (LENGTH(VALUE) [1] 5 AND VALUE ~ '[2]' AND VALUE !~ '[3]');
The zipcode must have length exactly 5 (using '='), match the regex for 5 digits (using '^[0-9]{5}$'), and not contain any non-digit characters (using '[^0-9]').