-
+
Data Definition
in a table. For many applications, however, the constraint they
provide is too coarse. For example, a column containing a product
price should probably only accept positive values. But there is no
- data type that accepts only positive numbers. Another issue is
+ standard data type that accepts only positive numbers. Another issue is
that you might want to constrain column data with respect to other
columns or rows. For example, in a table containing product
information, there should only be one row for each product number.
IS NOT NULL), but in
PostgreSQL creating an explicit
not-null constraint is more efficient. The drawback is that you
- cannot give explicit names to not-null constraints created that
+ cannot give explicit names to not-null constraints created this
way.
columns included in the constraint are equal.
However, null values are not considered equal in this
comparison. That means even in the presence of a
- unique constraint it is possible to store an unlimited number of
+ unique constraint it is possible to store duplicate
rows that contain a null value in at least one of the constrained
columns. This behavior conforms to the SQL standard, but we have
heard that other SQL databases may not follow this rule. So be
\n is a newline, \r is a
carriage return, \t is a tab. Also supported is
\digits, where
- ddd represents an octal byte value, and
+ digits represents an octal byte value, and
\xhexdigits, where
hexdigits represents a hexadecimal byte value.
(It is your responsibility that the byte sequences you create are
is that it does not work for array types; use ::
or CAST() to specify the type of an array constant.
+
+ The CAST()> syntax conforms to SQL. The
+ type 'string'
+ syntax is a generalization of the standard: SQL specifies this syntax only
+ for a few datatypes, but
PostgreSQL allows it
+ for all types. The syntax with
+
:: is historical
PostgreSQL
+ usage, as is the function-call syntax.
+
LANGUAGE SQL;
- Here the $1 will be replaced by the first
- function argument when the function is invoked.
+ Here the $1 references the value of the first
+ function argument whenever the function is invoked.