2
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_domain.sgml,v 1.13 2004-11-27 21:27:07 petere Exp $
3
PostgreSQL documentation
6
<refentry id="SQL-ALTERDOMAIN">
8
<refentrytitle id="sql-alterdomain-title">ALTER DOMAIN</refentrytitle>
9
<refmiscinfo>SQL - Language Statements</refmiscinfo>
17
change the definition of a domain
21
<indexterm zone="sql-alterdomain">
22
<primary>ALTER DOMAIN</primary>
27
ALTER DOMAIN <replaceable class="PARAMETER">name</replaceable>
28
{ SET DEFAULT <replaceable class="PARAMETER">expression</replaceable> | DROP DEFAULT }
29
ALTER DOMAIN <replaceable class="PARAMETER">name</replaceable>
30
{ SET | DROP } NOT NULL
31
ALTER DOMAIN <replaceable class="PARAMETER">name</replaceable>
32
ADD <replaceable class="PARAMETER">domain_constraint</replaceable>
33
ALTER DOMAIN <replaceable class="PARAMETER">name</replaceable>
34
DROP CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable> [ RESTRICT | CASCADE ]
35
ALTER DOMAIN <replaceable class="PARAMETER">name</replaceable>
36
OWNER TO <replaceable class="PARAMETER">new_owner</replaceable>
41
<title>Description</title>
44
<command>ALTER DOMAIN</command> changes the definition of an existing domain.
45
There are several sub-forms:
50
<term>SET/DROP DEFAULT</term>
53
These forms set or remove the default value for a domain. Note
54
that defaults only apply to subsequent <command>INSERT</command>
55
commands; they do not affect rows already in a table using the domain.
61
<term>SET/DROP NOT NULL</term>
64
These forms change whether a domain is marked to allow NULL
65
values or to reject NULL values. You may only <literal>SET NOT NULL</>
66
when the columns using the domain contain no null values.
72
<term>ADD <replaceable class="PARAMETER">domain_constraint</replaceable></term>
75
This form adds a new constraint to a domain using the same syntax as
76
<xref linkend="SQL-CREATEDOMAIN" endterm="SQL-CREATEDOMAIN-TITLE">.
77
This will only succeed if all columns using the domain satisfy the
84
<term>DROP CONSTRAINT</term>
87
This form drops constraints on a domain.
96
This form changes the owner of the domain to the specified user.
103
You must own the domain to use <command>ALTER DOMAIN</>; except for
104
<command>ALTER DOMAIN OWNER</>, which may only be executed by a superuser.
109
<title>Parameters</title>
114
<term><replaceable class="PARAMETER">name</replaceable></term>
117
The name (possibly schema-qualified) of an existing domain to
124
<term><replaceable class="PARAMETER">domain_constraint</replaceable></term>
127
New domain constraint for the domain.
133
<term><replaceable class="PARAMETER">constraint_name</replaceable></term>
136
Name of an existing constraint to drop.
142
<term><literal>CASCADE</literal></term>
145
Automatically drop objects that depend on the constraint.
151
<term><literal>RESTRICT</literal></term>
154
Refuse to drop the constraint if there are any dependent
155
objects. This is the default behavior.
161
<term><replaceable class="PARAMETER">new_owner</replaceable></term>
164
The user name of the new owner of the domain.
174
<title>Examples</title>
177
To add a <literal>NOT NULL</literal> constraint to a domain:
179
ALTER DOMAIN zipcode SET NOT NULL;
181
To remove a <literal>NOT NULL</literal> constraint from a domain:
183
ALTER DOMAIN zipcode DROP NOT NULL;
188
To add a check constraint to a domain:
190
ALTER DOMAIN zipcode ADD CONSTRAINT zipchk CHECK (char_length(VALUE) = 5);
195
To remove a check constraint from a domain:
197
ALTER DOMAIN zipcode DROP CONSTRAINT zipchk;
203
<title>Compatibility</title>
206
The <command>ALTER DOMAIN</command> statement is compatible with SQL:1999,
207
except for the <literal>OWNER</> variant, which is a
208
<productname>PostgreSQL</productname> extension.
213
<!-- Keep this comment at the end of the file
218
sgml-minimize-attributes:nil
219
sgml-always-quote-attributes:t
222
sgml-parent-document:nil
223
sgml-default-dtd-file:"../reference.ced"
224
sgml-exposed-tags:nil
225
sgml-local-catalogs:"/usr/lib/sgml/catalog"
226
sgml-local-ecat-files:nil