A declaration statement allows the developer to define variables and constants. The general syntax of a variable declaration is as follows:
name [ CONSTANT ] type [ COLLATE collation_name ] [ NOT NULL ] [ { DEFAULT | := | = } expression ];
The description is as follows:
- name: The name should follow the naming rules that were discussed in Chapter 3, PostgreSQL Basic Building Blocks. For example, the name should not start with an integer.
- CONSTANT: The variable cannot be assigned another value after the initialization. This is useful in defining constant variables, such as PI.
- type: This type of the variable can be simple, such as an integer, user-defined data type, pseudo type, and record. Since a type is created implicitly ...