November 2019
Beginner to intermediate
470 pages
11h 59m
English
As stated already in this chapter, functions in PostgreSQL are pretty universal, and can be used in many different contexts. If you want to use functions to improve your data quality, you can use a CREATE DOMAIN clause:
test=# \h CREATE DOMAINCommand: CREATE DOMAINDescription: define a new domainSyntax:CREATE DOMAIN name [ AS ] data_type [ COLLATE collation ] [ DEFAULT expression ] [ constraint [ ... ] ]where constraint is:[ CONSTRAINT constraint_name ]{ NOT NULL | NULL | CHECK (expression) }URL: https://www.postgresql.org/docs/12/sql-createdomain.html
In this example, the PL/Perl function will be used to create a domain called email, which, in turn, can be used as a data type.
The following code shows ...