PostgreSQL is an object-relational database management system based on POSTGRES, Version 4.2
.
Model Features:
- complex queries
- foreign keys
- triggers
- updatable views
- transactional integrity
- multiversion concurrency control
Feasible, by adding new:
- data types
- functions
- operators
- aggregate functions
- index methods
- procedural languages
Concepts
- use
NULLS FIRST
andNULLS LAST
options to explicitly specify the order ofNULL
with other non-null
values - PostgreSQL uses true, ’t’, ’true’, ‘y’, ‘yes’, ‘1’ to represent true and false, ‘f’, ‘false’, ’n’, ’no’, and ‘0’ to represent false.
- uses the
OR
operator to combine false withnull
, which returnsnull
- PostgreSQL supports the FETCH clause to skip a certain number of rows and then fetch a specific number of rows.
- The pattern
_her%
matches any strings that satisfy the following conditions- The first character can be anything.
- The following characters must be ‘her’.
- There can be any number (including zero) of characters after ‘her’.
- If table1 has n rows and table2 has m rows, the CROSS JOIN will return a result set that has
nxm
rows. - A common table expression (CTE) allows you to create a temporary result set within a query.
|
|
data types
- Boolean
- Character types such as char, varchar, and text.
- Numeric types such as integer and floating-point number.
- Temporal types such as date, time, timestamp, and interval
- UUID for storing Universally Unique Identifiers
- Array for storing array strings, numbers, etc.
- JSON stores JSON data
- hstore stores key-value pair
- Special types such as network address and geometric data.
Window Functions
- the
AVG()
function reduces the number of rows returned by the queries. - The term window describes the set of rows on which the window function operates. A window function returns values from the rows in a window.
- For instance, the following query returns the product name, the price, product group name, along with the average prices of each product group.
|
|
Transaction
|
|
import/export
|
|
alter
- add column
- drop column
- change the data type of column
- rename a column
- set a default value for the column
- add a constraint to column
- rename a table
Stored Procedures
TODO
Triggers
|
|
Views
use the results of a complex query as another table.
|
|
Rules
A Rule is a description of how to alter the parsed query tree.
Basic Structure
Cautions
- it’s illegal to use
"
in sql queries.