~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to doc/src/sgml/ref/alter_domain.sgml

  • Committer: alvherre
  • Date: 2005-12-16 21:24:52 UTC
  • Revision ID: svn-v4:db760fc0-0f08-0410-9d63-cc6633f64896:trunk:1
Initial import of the REL8_0_3 sources from the Pgsql CVS repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!--
 
2
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_domain.sgml,v 1.13 2004-11-27 21:27:07 petere Exp $
 
3
PostgreSQL documentation
 
4
-->
 
5
 
 
6
<refentry id="SQL-ALTERDOMAIN">
 
7
 <refmeta>
 
8
  <refentrytitle id="sql-alterdomain-title">ALTER DOMAIN</refentrytitle>
 
9
  <refmiscinfo>SQL - Language Statements</refmiscinfo>
 
10
 </refmeta>
 
11
 
 
12
 <refnamediv>
 
13
  <refname>
 
14
   ALTER DOMAIN
 
15
  </refname>
 
16
  <refpurpose>
 
17
   change the definition of a domain
 
18
  </refpurpose>
 
19
 </refnamediv>
 
20
 
 
21
 <indexterm zone="sql-alterdomain">
 
22
  <primary>ALTER DOMAIN</primary>
 
23
 </indexterm>
 
24
 
 
25
 <refsynopsisdiv>
 
26
  <synopsis>
 
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> 
 
37
  </synopsis>
 
38
 </refsynopsisdiv>
 
39
 
 
40
 <refsect1>
 
41
  <title>Description</title>
 
42
 
 
43
  <para>
 
44
   <command>ALTER DOMAIN</command> changes the definition of an existing domain.
 
45
   There are several sub-forms:
 
46
  </para>
 
47
 
 
48
  <variablelist>
 
49
   <varlistentry>
 
50
    <term>SET/DROP DEFAULT</term>
 
51
    <listitem>
 
52
     <para>
 
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.
 
56
     </para>
 
57
    </listitem>
 
58
   </varlistentry>
 
59
 
 
60
   <varlistentry>
 
61
    <term>SET/DROP NOT NULL</term>
 
62
    <listitem>
 
63
     <para>
 
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.
 
67
     </para>
 
68
    </listitem>
 
69
   </varlistentry>
 
70
 
 
71
   <varlistentry>
 
72
    <term>ADD <replaceable class="PARAMETER">domain_constraint</replaceable></term>
 
73
    <listitem>
 
74
     <para>
 
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
 
78
      new constraint.
 
79
     </para>
 
80
    </listitem>
 
81
   </varlistentry>
 
82
 
 
83
   <varlistentry>
 
84
    <term>DROP CONSTRAINT</term>
 
85
    <listitem>
 
86
     <para>
 
87
      This form drops constraints on a domain.
 
88
     </para>
 
89
    </listitem>
 
90
   </varlistentry>
 
91
 
 
92
   <varlistentry>
 
93
    <term>OWNER</term>
 
94
    <listitem>
 
95
     <para>
 
96
      This form changes the owner of the domain to the specified user.
 
97
     </para>
 
98
    </listitem>
 
99
   </varlistentry>
 
100
  </variablelist>
 
101
 
 
102
  <para>
 
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.
 
105
  </para>
 
106
 </refsect1>
 
107
 
 
108
 <refsect1>
 
109
  <title>Parameters</title>
 
110
 
 
111
   <para>
 
112
    <variablelist>
 
113
     <varlistentry>
 
114
      <term><replaceable class="PARAMETER">name</replaceable></term>
 
115
      <listitem>
 
116
       <para>
 
117
        The name (possibly schema-qualified) of an existing domain to
 
118
        alter.
 
119
       </para>
 
120
      </listitem>
 
121
     </varlistentry>
 
122
 
 
123
     <varlistentry>
 
124
      <term><replaceable class="PARAMETER">domain_constraint</replaceable></term>
 
125
      <listitem>
 
126
       <para>
 
127
        New domain constraint for the domain.
 
128
       </para>
 
129
      </listitem>
 
130
     </varlistentry>
 
131
 
 
132
     <varlistentry>
 
133
      <term><replaceable class="PARAMETER">constraint_name</replaceable></term>
 
134
      <listitem>
 
135
       <para>
 
136
        Name of an existing constraint to drop.
 
137
       </para>
 
138
      </listitem>
 
139
     </varlistentry>
 
140
 
 
141
     <varlistentry>
 
142
      <term><literal>CASCADE</literal></term>
 
143
      <listitem>
 
144
       <para>
 
145
        Automatically drop objects that depend on the constraint.
 
146
       </para>
 
147
      </listitem>
 
148
     </varlistentry>
 
149
 
 
150
     <varlistentry>
 
151
      <term><literal>RESTRICT</literal></term>
 
152
      <listitem>
 
153
       <para>
 
154
        Refuse to drop the constraint if there are any dependent
 
155
        objects. This is the default behavior.
 
156
       </para>
 
157
      </listitem>
 
158
     </varlistentry>
 
159
 
 
160
     <varlistentry>
 
161
      <term><replaceable class="PARAMETER">new_owner</replaceable></term>
 
162
      <listitem>
 
163
       <para>
 
164
        The user name of the new owner of the domain.
 
165
       </para>
 
166
      </listitem>
 
167
     </varlistentry>
 
168
 
 
169
    </variablelist>
 
170
   </para>
 
171
  </refsect1>
 
172
 
 
173
 <refsect1>
 
174
  <title>Examples</title>
 
175
 
 
176
  <para>
 
177
   To add a <literal>NOT NULL</literal> constraint to a domain:
 
178
   <programlisting>
 
179
ALTER DOMAIN zipcode SET NOT NULL;
 
180
   </programlisting>
 
181
   To remove a <literal>NOT NULL</literal> constraint from a domain:
 
182
   <programlisting>
 
183
ALTER DOMAIN zipcode DROP NOT NULL;
 
184
   </programlisting>
 
185
  </para>
 
186
 
 
187
  <para> 
 
188
   To add a check constraint to a domain:
 
189
   <programlisting>
 
190
ALTER DOMAIN zipcode ADD CONSTRAINT zipchk CHECK (char_length(VALUE) = 5);
 
191
   </programlisting>
 
192
  </para>
 
193
 
 
194
  <para> 
 
195
   To remove a check constraint from a domain:
 
196
   <programlisting>
 
197
ALTER DOMAIN zipcode DROP CONSTRAINT zipchk;
 
198
   </programlisting>
 
199
  </para>
 
200
 </refsect1>
 
201
 
 
202
 <refsect1>
 
203
  <title>Compatibility</title>
 
204
    
 
205
  <para>
 
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.
 
209
  </para>
 
210
 </refsect1>
 
211
</refentry>
 
212
 
 
213
<!-- Keep this comment at the end of the file
 
214
Local variables:
 
215
mode: sgml
 
216
sgml-omittag:nil
 
217
sgml-shorttag:t
 
218
sgml-minimize-attributes:nil
 
219
sgml-always-quote-attributes:t
 
220
sgml-indent-step:1
 
221
sgml-indent-data: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
 
227
End:
 
228
-->