Altering a Domain
To change the attributes of a domain, use the DDL statement ALTER DOMAIN
.With this statement you can:
-
rename the domain
-
change the data type
-
drop the current default value
-
set a new default value
-
drop the
NOT NULL
constraint -
set the
NOT NULL
constraint -
drop an existing
CHECK
constraint -
add a new
CHECK
constraint
ALTER DOMAIN name [{TO new_name}] [{SET DEFAULT { <literal> | NULL | <context_var> } | DROP DEFAULT}] [{SET | DROP} NOT NULL ] [{ADD [CONSTRAINT] CHECK (<dom_condition>) | DROP CONSTRAINT}] [{TYPE <datatype>}]
ALTER DOMAIN STORE_GRP SET DEFAULT -1;
When changing a domain, its dependencies must be taken into account: whether there are table columns, any variables, input and/or output parameters with the type of this domain declared in the PSQL code.If you change domains in haste, without carefully checking them, your code may stop working!
Important
|
When you convert data types in a domain, you must not perform any conversions that may result in data loss.Also, for example, if you convert |
ALTER DOMAIN
in the Data Definition (DDL) Statements chapter.