Skip to Content
Mastering PostgreSQL 12 - Third Edition
book

Mastering PostgreSQL 12 - Third Edition

by Hans-Jürgen Schönig
November 2019
Beginner to intermediate
470 pages
11h 59m
English
Packt Publishing
Content preview from Mastering PostgreSQL 12 - Third Edition

Using PL/Perl for data type abstraction

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering PostgreSQL 11 - Second Edition

Mastering PostgreSQL 11 - Second Edition

Hans-Jürgen Schönig
Learning PostgreSQL 11 - Third Edition

Learning PostgreSQL 11 - Third Edition

Christopher Travers, Andrey Volkov
PostgreSQL Server Programming - Second Edition

PostgreSQL Server Programming - Second Edition

Usama Dar, Hannu Krosing, Jim Mlodgenski, Kirk Roybal

Publisher Resources

ISBN: 9781838988821Supplemental Content