|
|
@ -678,35 +678,17 @@ |
|
|
|
The CHECK constraint specifies a rule that a group of one or |
|
|
|
The CHECK constraint specifies a rule that a group of one or |
|
|
|
more columns of a table may contain only those values allowed by |
|
|
|
more columns of a table may contain only those values allowed by |
|
|
|
the rule. |
|
|
|
the rule. |
|
|
|
</para> |
|
|
|
|
|
|
|
<PARA> |
|
|
|
|
|
|
|
The CHECK constraint is either a table constraint or a column |
|
|
|
The CHECK constraint is either a table constraint or a column |
|
|
|
constraint. |
|
|
|
constraint. |
|
|
|
</PARA> |
|
|
|
</PARA> |
|
|
|
<PARA> |
|
|
|
<PARA> |
|
|
|
PostgreSQL automatically creates an unique index to assure |
|
|
|
PostgreSQL automatically creates an unique index to assure |
|
|
|
data integrity. (See CREATE INDEX statement) |
|
|
|
data integrity (See CREATE INDEX statement). |
|
|
|
</PARA> |
|
|
|
|
|
|
|
<PARA> |
|
|
|
|
|
|
|
The SQL92 CHECK column constraints can only be defined on, and |
|
|
|
The SQL92 CHECK column constraints can only be defined on, and |
|
|
|
refer to, one column of the table. PostgreSQL does not have |
|
|
|
refer to, one column of the table. PostgreSQL does not have |
|
|
|
this restriction. |
|
|
|
this restriction. |
|
|
|
</PARA> |
|
|
|
</PARA> |
|
|
|
</refsect3> |
|
|
|
</refsect3> |
|
|
|
<refsect3> |
|
|
|
|
|
|
|
<title>BUGS in CHECK constraint</title> |
|
|
|
|
|
|
|
<PARA> |
|
|
|
|
|
|
|
The following CHECK constraints gives a parse error like: |
|
|
|
|
|
|
|
<programlisting> |
|
|
|
|
|
|
|
ERROR: parser: parse error at or near "opname": |
|
|
|
|
|
|
|
</programlisting> |
|
|
|
|
|
|
|
<simplelist columns="1"> |
|
|
|
|
|
|
|
<member>CHECK ( <replaceable class="parameter">column</replaceable> BETWEEN 'A' AND 'Z' )</member> |
|
|
|
|
|
|
|
<member>CHECK ( <replaceable class="parameter">column</replaceable> IN ('A','Z'))</member> |
|
|
|
|
|
|
|
<member>CHECK ( <replaceable class="parameter">column</replaceable> NOT LIKE 'A%')</member> |
|
|
|
|
|
|
|
</simplelist> |
|
|
|
|
|
|
|
</para> |
|
|
|
|
|
|
|
</refsect3> |
|
|
|
|
|
|
|
</REFSECT2> |
|
|
|
</REFSECT2> |
|
|
|
|
|
|
|
|
|
|
|
<REFSECT2 ID="R2-SQL-PRIMARYKEY-1"> |
|
|
|
<REFSECT2 ID="R2-SQL-PRIMARYKEY-1"> |
|
|
@ -1015,10 +997,11 @@ |
|
|
|
</programlisting> |
|
|
|
</programlisting> |
|
|
|
<para> |
|
|
|
<para> |
|
|
|
Temporary tables are not currently available in <productname>Postgres</productname>. |
|
|
|
Temporary tables are not currently available in <productname>Postgres</productname>. |
|
|
|
|
|
|
|
<tip> |
|
|
|
<para> |
|
|
|
<para> |
|
|
|
TIP: In the current release of <productname>Postgres</productname> (v6.3.2), to create a temporary |
|
|
|
In the current release of <productname>Postgres</productname> (v6.4), to create a temporary |
|
|
|
table you must create and drop the table by explicit commands. |
|
|
|
table you must create and drop the table by explicit commands. |
|
|
|
</para> |
|
|
|
</tip> |
|
|
|
|
|
|
|
|
|
|
|
<REFSECT3 ID="R3-SQL-UNIQUECLAUSE-1"> |
|
|
|
<REFSECT3 ID="R3-SQL-UNIQUECLAUSE-1"> |
|
|
|
<REFSECT3INFO> |
|
|
|
<REFSECT3INFO> |
|
|
@ -1067,6 +1050,13 @@ Temporary tables are not currently available in <productname>Postgres</productna |
|
|
|
</synopsis> |
|
|
|
</synopsis> |
|
|
|
</REFSECT3> |
|
|
|
</REFSECT3> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- |
|
|
|
|
|
|
|
I can't figure out why DEFAULT clause is different from what we already have. |
|
|
|
|
|
|
|
Perhaps because CURRENT_USER and CURRENT_DATE have specific types (currently |
|
|
|
|
|
|
|
the "name" type), if you aren't careful then the types won't match up with |
|
|
|
|
|
|
|
the column. Not our problem... |
|
|
|
|
|
|
|
- Thomas 1998-08-16 |
|
|
|
|
|
|
|
|
|
|
|
<REFSECT3 ID="R3-SQL-DEFAULTCLAUSE-1"> |
|
|
|
<REFSECT3 ID="R3-SQL-DEFAULTCLAUSE-1"> |
|
|
|
<REFSECT3INFO> |
|
|
|
<REFSECT3INFO> |
|
|
|
<DATE>1998-04-15</DATE> |
|
|
|
<DATE>1998-04-15</DATE> |
|
|
@ -1080,12 +1070,12 @@ Temporary tables are not currently available in <productname>Postgres</productna |
|
|
|
or a domain. |
|
|
|
or a domain. |
|
|
|
</para> |
|
|
|
</para> |
|
|
|
<synopsis> |
|
|
|
<synopsis> |
|
|
|
DEFAULT <replaceable class="parameter">literal</replaceable> | |
|
|
|
DEFAULT niladic USER function | |
|
|
|
niladic USER function | |
|
|
|
niladic datetime function | |
|
|
|
niladic datetime function | |
|
|
|
NULL |
|
|
|
NULL |
|
|
|
|
|
|
|
</synopsis> |
|
|
|
</synopsis> |
|
|
|
</refsect3> |
|
|
|
</refsect3> |
|
|
|
|
|
|
|
--> |
|
|
|
|
|
|
|
|
|
|
|
<REFSECT3 ID="R3-SQL-CONSTRAINT-3"> |
|
|
|
<REFSECT3 ID="R3-SQL-CONSTRAINT-3"> |
|
|
|
<REFSECT3INFO> |
|
|
|
<REFSECT3INFO> |
|
|
@ -1096,7 +1086,7 @@ Temporary tables are not currently available in <productname>Postgres</productna |
|
|
|
</TITLE> |
|
|
|
</TITLE> |
|
|
|
<PARA> |
|
|
|
<PARA> |
|
|
|
SQL92 specifies some additional capabilities for CONSTRAINTs, |
|
|
|
SQL92 specifies some additional capabilities for CONSTRAINTs, |
|
|
|
it also defines assertions and domain constraints. |
|
|
|
and also defines assertions and domain constraints. |
|
|
|
</PARA> |
|
|
|
</PARA> |
|
|
|
<PARA> |
|
|
|
<PARA> |
|
|
|
An assertion is a special type of integrity constraint and share |
|
|
|
An assertion is a special type of integrity constraint and share |
|
|
@ -1209,12 +1199,19 @@ Temporary tables are not currently available in <productname>Postgres</productna |
|
|
|
CHECK clause |
|
|
|
CHECK clause |
|
|
|
</TITLE> |
|
|
|
</TITLE> |
|
|
|
<PARA> |
|
|
|
<PARA> |
|
|
|
SQL92 specifies some additional capabilities for CHECK: |
|
|
|
SQL92 specifies some additional capabilities for CHECK in either |
|
|
|
|
|
|
|
table or column constraints. |
|
|
|
</PARA> |
|
|
|
</PARA> |
|
|
|
|
|
|
|
<!-- |
|
|
|
|
|
|
|
Constraints associated with domains do not need to be mentioned here, |
|
|
|
|
|
|
|
even though it is the case that a domain constraint may possibly |
|
|
|
|
|
|
|
affect a column or a table. |
|
|
|
|
|
|
|
- Thomas 1998-08-16 |
|
|
|
<para> |
|
|
|
<para> |
|
|
|
A CHECK constraint is either a table constraint, a column |
|
|
|
A CHECK constraint is either a table constraint, a column |
|
|
|
constraint or a domain constraint. |
|
|
|
constraint or a domain constraint. |
|
|
|
</para> |
|
|
|
</para> |
|
|
|
|
|
|
|
--> |
|
|
|
<para> |
|
|
|
<para> |
|
|
|
table constraint definition: |
|
|
|
table constraint definition: |
|
|
|
</para> |
|
|
|
</para> |
|
|
@ -1233,6 +1230,7 @@ Temporary tables are not currently available in <productname>Postgres</productna |
|
|
|
[ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ] |
|
|
|
[ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ] |
|
|
|
[ [ NOT ] DEFERRABLE ] |
|
|
|
[ [ NOT ] DEFERRABLE ] |
|
|
|
</synopsis> |
|
|
|
</synopsis> |
|
|
|
|
|
|
|
<!-- |
|
|
|
<para> |
|
|
|
<para> |
|
|
|
domain constraint definition: |
|
|
|
domain constraint definition: |
|
|
|
</para> |
|
|
|
</para> |
|
|
@ -1253,6 +1251,7 @@ Temporary tables are not currently available in <productname>Postgres</productna |
|
|
|
ALTER DOMAIN cities |
|
|
|
ALTER DOMAIN cities |
|
|
|
ADD CONSTRAINT new_city CHECK (VALUE LIKE 'L%'); |
|
|
|
ADD CONSTRAINT new_city CHECK (VALUE LIKE 'L%'); |
|
|
|
</programlisting> |
|
|
|
</programlisting> |
|
|
|
|
|
|
|
--> |
|
|
|
</refsect3> |
|
|
|
</refsect3> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|