1.2.2 PostgreSQL
1.2.2.1 S6 Statement
Review the query execution plan, and the subquery is optimized (materialized so that the subquery results are cached, and the subquery is executed only once).
postgres=# EXPLAIN SELECT * from T3 WHERE b3 >=
There are multiple tables in the PostgreSQL database test environment that do not have a PRIMARY KEY constraint and only one serial field. Now you need to add to the table with no primary key, the field ID of the serial type.
First, how do I find
Business extension fields are often stored in the database using JSON-formatted data, which involves a headache, assuming that a value in the extension field should be used as a query condition, and PostgreSQL itself supports this query.Example:
The introduction recently collated some of the most common commands for PostgreSQL, for reference 1 only. Common commands:# time Word Fu timestampSelectExtract (Epoch fromDate'2018-04-11 23:59:59')); #1523404800# Timestamp to time stringSelectDate
Constraint type: Check constraint, non-null constraint, UNIQUE constraint, primary key, foreign key1. CHECK constraintsSetting a value in a field must satisfy the condition of the constraint expression.Example: Limiting the age of people in 0~120 ,
In the process of installing the PG database, the installation directory and data storage directory and port will be selected, and you need to select Local, if you use the default , and set your own password to start the installation, the earlier
Encountered an error in postgresql9.2, that is, in the stream replication mode, if you use Psql to access the standby machine, no matter what SQL statement executed, will be reported errordata_stack_size exceeded error.The online search for this
Pip Install PSYCOPGPython PSYCOPG2 Module APIsThe following is an important module routine for PSYCOPG2 to meet the Python program's work with the PostgreSQL database.
S.N.
API & Description
1
psycopg2.connect
Every movie needs a director and every rented movie needs to exist in the store. How does we make sure something in another table exists before inserting new data? This lesson would teach us about foreign keys and references.CREATE TABLEdirectors
Let's say we have a bank. Our bank wants to give each account for each user a unique name, for instance, "Personal" or "Checking." How can we do sure each account have a unique name for each user?ADD UNIQUE constraint when create a new table:CREATE
The upgrade in PostgreSQL, if for a minor version of the upgrade, such as 9.6.1 upgrade to 9.6.2 (the current latest version), Only 9.6.2 version of the software to replace the 9.6.1 version of the software can be, do not need to do extra work,
Under Mac, you can use homebrew to install PostgreSQL directly:
1
brew installpostgresql -v
For a moment, PostgreSQL will be installed. Next is the initial database, execute the command at the terminal, and initially
PostgreSQL is a famous open-source database. Recently, the PostgreSQL Global Development Team released the latest version 9.2, which greatly improved the performance and added built-in support for JSON.
As early as the release of beta in March,
I have to say that at this point, PostgreSQL is very powerful and no less powerful than any large commercial database. It is not that complicated to add custom functions.
The following example adds the following functions: Test (), concat_text
1. log ConfigurationThe system log and error log of postgresql are directly output by default and are not written to files. If you want to view these logs, modify PostgreSQL. conf as follows:
Log_destination = 'stderr'Logging_collector =
Processing of null values in PostgreSQL When a field value is null in the addition, subtraction, multiplication, division, and Division operations, the output results often disappoint us and we cannot get the expected values, you can use coalesce to
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service