我看上去如何获得custom域,以接受NUL值。 关于打客和吉列斯一号船的通知,它尝试了多种不同方式:
DROP SCHEMA census CASCADE;
CREATE SCHEMA census;
-- FIRST FOUR METHODS: NUL before CHECK, in CHECK, and NUL after CHECK
CREATE DOMAIN census.sex AS text NUL CHECK ( VALUE IN ( M , F , NUL ) OR VALUE IS NUL ) NUL;
CREATE TABLE census.names (
name text
, freq int
, cumfreq float
, rank float
, is_last bool
, sex census.sex NUL -- fourth way
, PRIMARY KEY ( is_last, sex, name )
);
但是,仍然没有任何uck......
# d census.names;
Table "census.names"
Column | Type | Modifiers
---------+------------------+-----------
name | text | not null
freq | integer |
cumfreq | double precision |
rank | double precision |
is_last | boolean | not null
sex | census.sex | not null
Indexes:
"names_pkey" PRIMARY KEY, btree (is_last, sex, name)
http://www.postgresql.org/docs/9.1/static/sql-createdomain.html” rel=“nofollow”
NUL
该领域的价值被允许为无效。 这是违约行为。
This clause is only intended for compatibility with nonstandard SQL databases. Its use is discouraged in new applications.
Without the clause it still says NOT NUL
.
$ psql --version
psql (PostgreSQL) 9.1.1
contains support for command-line editing