.\" auto-generated by docbook2man-spec $Revision: 1.1.1.1 $ CREATE DOMAIN - Online Linux Manual PageSection : 7
Updated : 2014-02-17
Source : SQL - Language Statements
Note : SQL Commands

NAMECREATE DOMAIN − define a new domain

SYNOPSISCREATE DOMAIN name [ AS ] data_type [ DEFAULT expression ] [ constraint [ ... ] ] where constraint is: [ CONSTRAINT constraint_name ] { NOT NULL | NULL | CHECK (expression) }

DESCRIPTIONCREATE DOMAIN creates a new domain. A domain is essentially a data type with optional constraints (restrictions on the allowed set of values). The user who defines a domain becomes its owner. If a schema name is given (for example, CREATE DOMAIN myschema.mydomain ...) then the domain is created in the specified schema. Otherwise it is created in the current schema. The domain name must be unique among the types and domains existing in its schema. Domains are useful for abstracting common constraints on fields into a single location for maintenance. For example, several tables might contain email address columns, all requiring the same CHECK constraint to verify the address syntax. Define a domain rather than setting up each table's constraint individually.

PARAMETERSname  The name (optionally schema-qualified) of a domain to be created. data_type  The underlying data type of the domain. This can include array specifiers. DEFAULT expression  The DEFAULT clause specifies a default value for columns of the domain data type. The value is any variable-free expression (but subqueries are not allowed). The data type of the default expression must match the data type of the domain. If no default value is specified, then the default value is the null value. The default expression will be used in any insert operation that does not specify a value for the column. If a default value is defined for a particular column, it overrides any default associated with the domain. In turn, the domain default overrides any default value associated with the underlying data type. CONSTRAINT constraint_name  An optional name for a constraint. If not specified, the system generates a name. NOT NULL  Values of this domain are not allowed to be null. NULL  Values of this domain are allowed to be null. This is the default. This clause is only intended for compatibility with nonstandard SQL databases. Its use is discouraged in new applications. CHECK (expression)  CHECK clauses specify integrity constraints or tests which values of the domain must satisfy. Each constraint must be an expression producing a Boolean result. It should use the key word VALUE to refer to the value being tested. Currently, CHECK expressions cannot contain subqueries nor refer to variables other than VALUE.

EXAMPLESThis example creates the us_postal_code data type and then uses the type in a table definition. A regular expression test is used to verify that the value looks like a valid US postal code: CREATE DOMAIN us_postal_code AS TEXT CHECK( VALUE ~ '^{5}$' OR VALUE ~ '^{5}-{4}$' ); CREATE TABLE us_snail_addy ( address_id SERIAL PRIMARY KEY, street1 TEXT NOT NULL, street2 TEXT, street3 TEXT, city TEXT NOT NULL, postal us_postal_code NOT NULL );

COMPATIBILITYThe command CREATE DOMAIN conforms to the SQL standard.

SEE ALSOALTER DOMAIN [alter_domain(7)], DROP DOMAIN [drop_domain(7)]
0
Johanes Gumabo
Data Size   :   10,711 byte
man-create_domain.7Build   :   2024-12-05, 20:55   :  
Visitor Screen   :   x
Visitor Counter ( page / site )   :   2 / 183,500
Visitor ID   :     :  
Visitor IP   :   18.118.184.36   :  
Visitor Provider   :   AMAZON-02   :  
Provider Position ( lat x lon )   :   39.962500 x -83.006100   :   x
Provider Accuracy Radius ( km )   :   1000   :  
Provider City   :   Columbus   :  
Provider Province   :   Ohio ,   :   ,
Provider Country   :   United States   :  
Provider Continent   :   North America   :  
Visitor Recorder   :   Version   :  
Visitor Recorder   :   Library   :  
Online Linux Manual Page   :   Version   :   Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page   :   Library   :   lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page   :   Library   :   lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base   :   Version   :   Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base   :   Library   :   lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36

Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.

ERROR : Need New Coding :         (rof_escape_sequence|91|create_domain.7|1|\" auto-generated by docbook2man-spec $Revision: 1.1.1.1 $ |.\\" auto-generated by docbook2man-spec $Revision: 1.1.1.1 $ )         (parse_manual_page_|249|create_domain.7|1|\"|.\\" auto-generated by docbook2man-spec $Revision: 1.1.1.1 $ )