PostgreSQL DOMAIN Data Type -2
PRACTICAL 2 .CREATION OF DOMAIN WITHOUT CONSTRAINT: Consider the following scenario on PostgreSQL 9.3: Step 1 .Create a domain with no constraints: postgres=# CREATE DOMAIN zipcode AS text; CREATE DOMAIN Step 2 .Add a named constraint: postgres=# ALTER DOMAIN zipcode ADD CONSTRAINT zipcheck CHECK (char_length(VALUE) = 3); ALTER DOMAIN Step 3 .Check the Domain whether created or not: postgres=# \dD List of domains Schema | Name | Type | Modifier | Check --------+-------------+------+----------+------------------------------------------------------------------ public | postal_code | text | | CHECK (VALUE ~ '^\d{5}$'::text OR VALUE ~ '^\d{5}-\d{4}$'::text) public | zipcode | text | | CHECK (char_length(VALUE) = 3) (2 rows) Step 4 .Ctreate a table using "zipcode" Data type postgres=# create table details (name...
Comments
Post a Comment