November 2019
Beginner to intermediate
470 pages
11h 59m
English
PostgreSQL 12 has more features that can simplify development. In many cases, the content of a column has to be derived from some other column. Traditionally, this has been implemented using a trigger. However, writing a trigger needs some coding and manual work. PostgreSQL has a better solution to the problem.
Suppose we want to store data in kilometers and nautical miles. One nautical mile translates to 1.852 km.
To make sure that nautical miles are always generated, the following syntax can be used:
test=# CREATE TABLE t_measurement ( t timestamp, km numeric, nm numeric GENERATED ALWAYS AS ...