diff --git a/doc/src/sgml/nullvalues.sgml b/doc/src/sgml/nullvalues.sgml index 6c7aaed37a..1a9e698a55 100644 --- a/doc/src/sgml/nullvalues.sgml +++ b/doc/src/sgml/nullvalues.sgml @@ -12,14 +12,14 @@ can be executed so long as the following table and rows are created first. - - CREATE TABLE null_examples ( - id bigint PRIMARY KEY, - value integer NULL - ); - INSERT INTO null_examples - VALUES (1, 1), (2, NULL), (3, 4); - + +CREATE TABLE null_examples ( + id bigint PRIMARY KEY, + value integer NULL +); +INSERT INTO null_examples +VALUES (1, 1), (2, NULL), (3, 4); + Meaning @@ -38,7 +38,7 @@ A null value, like all values, must have a data type, and is valid for all data types. - As noted in the synatx chapter, + As noted in the syntax chapter, a null value literal is written using the NULL keyword. Its type is the pseudo-type unknown but can be cast to any concrete data type. @@ -60,11 +60,11 @@ - SELECT text NULL; +SELECT text NULL; - ERROR: column "text" does not exist - LINE 1: select text NUll; +ERROR: column "text" does not exist +LINE 1: select text NUll; @@ -267,28 +267,28 @@ the value will be null. The common way this happens is by including the domain column's table on the right side of a left join. - BEGIN; - CREATE DOMAIN domain_example AS integer NOT NULL; - CREATE TABLE domain_examples (de_id bigint PRIMARY KEY, de_value domain_example); - INSERT INTO domain_examples VALUES (1, 1), (2, 2); - SELECT *, pg_typeof(de_value) - FROM null_examples AS ne - LEFT JOIN domain_examples AS de ON ne.id = de.de_id; - ROLLBACK; - - - BEGIN - CREATE DOMAIN - CREATE TABLE - INSERT 0 2 - id | value | de_id | de_value | pg_typeof - ----+-------+-------+----------+---------------- - 1 | 1 | 1 | 1 | domain_example - 2 | | 2 | 2 | domain_example - 3 | 4 | | | domain_example - (3 rows) - - ROLLBACK +BEGIN; +CREATE DOMAIN domain_example AS integer NOT NULL; +CREATE TABLE domain_examples (de_id bigint PRIMARY KEY, de_value domain_example); +INSERT INTO domain_examples VALUES (1, 1), (2, 2); +SELECT *, pg_typeof(de_value) +FROM null_examples AS ne +LEFT JOIN domain_examples AS de ON ne.id = de.de_id; +ROLLBACK; + + +BEGIN +CREATE DOMAIN +CREATE TABLE +INSERT 0 2 + id | value | de_id | de_value | pg_typeof +----+-------+-------+----------+---------------- + 1 | 1 | 1 | 1 | domain_example + 2 | | 2 | 2 | domain_example + 3 | 4 | | | domain_example +(3 rows) + +ROLLBACK Please see the details in the notes on the create domain page for another example, as well as @@ -698,24 +698,24 @@ when an expression evaulates to a null value, is to allow the row to be inserted - the same as a true result. - BEGIN; - ALTER TABLE null_examples ADD CONSTRAINT value_not_1 CHECK (value != 1); - ROLLBACK; +BEGIN; +ALTER TABLE null_examples ADD CONSTRAINT value_not_1 CHECK (value != 1); +ROLLBACK; - BEGIN - ERROR: check constraint "value_not_1" of relation "null_examples" is violated by some row - ROLLBACK +BEGIN +ERROR: check constraint "value_not_1" of relation "null_examples" is violated by some row +ROLLBACK - BEGIN; - ALTER TABLE null_examples ADD CONSTRAINT value_not_10 CHECK (value != 10); - ROLLBACK; +BEGIN; +ALTER TABLE null_examples ADD CONSTRAINT value_not_10 CHECK (value != 10); +ROLLBACK; - BEGIN - ALTER TABLE - ROLLBACK +BEGIN +ALTER TABLE +ROLLBACK We are using a transaction (begin and rollback) and the alter table command to add two constraints to our null_examples table. The first constraint prohibits rows with a value @@ -817,31 +817,31 @@ - BEGIN; - CREATE UNIQUE INDEX value_nulls_distinct_implicit ON null_examples (value); - CREATE UNIQUE INDEX value_nulls_distinct_explicit ON null_examples (value) NULLS DISTINCT; - INSERT INTO null_examples VALUES (4, NULL); - ROLLBACK; +BEGIN; +CREATE UNIQUE INDEX value_nulls_distinct_implicit ON null_examples (value); +CREATE UNIQUE INDEX value_nulls_distinct_explicit ON null_examples (value) NULLS DISTINCT; +INSERT INTO null_examples VALUES (4, NULL); +ROLLBACK; - BEGIN - CREATE INDEX - CREATE INDEX - INSERT 0 1 - ROLLBACK +BEGIN +CREATE INDEX +CREATE INDEX +INSERT 0 1 +ROLLBACK - BEGIN; - CREATE UNIQUE INDEX value_nulls_not_distinct_explicit ON null_examples (value) NULLS NOT DISTINCT; - INSERT INTO null_examples VALUES (4, NULL); - ROLLBACK; +BEGIN; +CREATE UNIQUE INDEX value_nulls_not_distinct_explicit ON null_examples (value) NULLS NOT DISTINCT; +INSERT INTO null_examples VALUES (4, NULL); +ROLLBACK; - BEGIN - CREATE INDEX - ERROR: duplicate key value violates unique constraint "value_nulls_not_distinct_explicit" - DETAIL: Key (value)=(null) already exists. - ROLLBACK +BEGIN +CREATE INDEX +ERROR: duplicate key value violates unique constraint "value_nulls_not_distinct_explicit" +DETAIL: Key (value)=(null) already exists. +ROLLBACK @@ -859,7 +859,7 @@ - Null Values in Partiton Keys + Null Values in Partition Keys At present this is typically a non-issue as PostgreSQL does not support a primary key that does not include partition key columns, and @@ -876,7 +876,7 @@ Null-Valued Settings - There are none. During initializion all settings are assigned a non-null value. + There are none. During initialization all settings are assigned a non-null value. This is mostly meaningful for custom settings,