Database Reference
In-Depth Information
Operator
Description
@
Absolute value
&
Bitwise AND
|
Bitwise OR
#
Bitwise XOR
~
Bitwise NOT
<<
Bitwise shift left
>>
Bitwise shift right
Apart from the logical, comparison, and mathematical operators, PostgreSQL also
has operators for strings, binary strings, bit strings, date/time, geometric, network
address, and text search. Details of these operators are beyond the scope of this topic
and can be studied in more detail in the PostgreSQL documentation available at
http://www.postgresql.org/docs/9.4/static/functions-string.html
.
Constraints in PostgreSQL
PostgreSQL offers support for constraints and has coverage of multiple-level
constraints. Constraints are used to enforce rules on data insertion in tables.
Only data that complies with the constraint rules is allowed to be added to
the table. The constraints present in PostgreSQL are:
• Unique constraints
• Not-null constraints
• Exclusion constrains
• Primary key constraints
• Foreign key constraints
• Check constraints
We will explain all of these constraints one by one with supportive examples.
Let's start with the unique constraints.
Unique constraints
A
unique constraint
is a constraint that at the time of an insertion operation makes
sure that data present in a column (or a group of columns) is unique with regard
to all rows already present in the table. Let's create a few tables using unique
constraints in the following manner: