1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
8 CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
10 HREF="mailto:pgsql-docs@postgresql.org"><LINK
12 TITLE="PostgreSQL 7.4.1 Documentation"
13 HREF="index.html"><LINK
16 HREF="sql-commands.html"><LINK
18 TITLE="ALTER DATABASE"
19 HREF="sql-alterdatabase.html"><LINK
21 TITLE="ALTER FUNCTION"
22 HREF="sql-alterfunction.html"><LINK
25 HREF="stylesheet.css"><META
27 CONTENT="2003-12-22T03:48:47"></HEAD
33 SUMMARY="Header navigation table"
43 >PostgreSQL 7.4.1 Documentation</TH
51 HREF="sql-alterdatabase.html"
60 HREF="sql-alterdatabase.html"
73 HREF="sql-alterfunction.html"
81 HREF="sql-alterfunction.html"
92 NAME="SQL-ALTERDOMAIN"
103 -- change the definition of a domain
109 CLASS="REFSYNOPSISDIV"
129 { SET | DROP } NOT NULL
136 >domain_constraint</VAR
144 >constraint_name</VAR
145 > [ RESTRICT | CASCADE ]
167 > changes the definition of an existing domain.
168 There are several sub-forms:
176 >SET/DROP DEFAULT</DT
179 > These forms set or remove the default value for a domain. Note
180 that defaults only apply to subsequent <TT
184 commands; they do not affect rows already in a table using the domain.
188 >SET/DROP NOT NULL</DT
191 > These forms change whether a domain is marked to allow NULL
192 values or to reject NULL values. You may only <TT
196 when the columns using the domain contain no null values.
202 >domain_constraint</VAR
206 > This form adds a new constraint to a domain using the same syntax as
208 HREF="sql-createdomain.html"
213 This will only succeed if all columns using the domain satisfy the
221 > This form drops constraints on a domain.
228 > This form changes the owner of the domain to the specified user.
234 > You must own the domain to use <TT
240 >ALTER DOMAIN OWNER</TT
241 >, which may only be executed by a superuser.
264 > The name (possibly schema-qualified) of an existing domain to
271 >domain_constraint</VAR
275 > New domain constraint for the domain.
281 >constraint_name</VAR
285 > Name of an existing constraint to drop.
292 > Automatically drop objects that depend on the constraint.
299 > Refuse to drop the constraint if there are any dependent
300 objects. This is the default behavior.
310 > The user name of the new owner of the domain.
326 > To add a NOT NULL constraint to a domain:
328 CLASS="PROGRAMLISTING"
329 >ALTER DOMAIN zipcode SET NOT NULL;
332 To remove a NOT NULL constraint from a domain:
334 CLASS="PROGRAMLISTING"
335 >ALTER DOMAIN zipcode DROP NOT NULL;
341 To add a check constraint to a domain:
343 CLASS="PROGRAMLISTING"
344 >ALTER DOMAIN zipcode ADD CONSTRAINT zipchk CHECK (char_length(VALUE) = 5);
350 To remove a check constraint from a domain:
352 CLASS="PROGRAMLISTING"
353 >ALTER DOMAIN zipcode DROP CONSTRAINT zipchk;
369 > statement is compatible with SQL99,
373 > variant, which is a
385 SUMMARY="Footer navigation table"
396 HREF="sql-alterdatabase.html"
414 HREF="sql-alterfunction.html"
430 HREF="sql-commands.html"