First, get the system time function
1.1 Get current full time
code is as follows
copy code
Select now (); david=# Select Now (); now ------------------------- ------ 2013-04-12 15:3
Chocolaty Direct InstallationThe psql operation has been prompted to enter the password. But the password has never been set. After the resolution as follows:After opening the file, temporarily change the MD5 to trustReload ConfigurationAfter
Packages that need to be installed pg_monz-2.1.tar.gz zabbix-sender-3.0.5-1.el7.x86_64.rpm zabbix-agent-3.0.17-1.el7.x86_64.rpm (省略安装)Pg_monz Installation1. Download Pg_monz Monitor Templatehttps://github.com/pg-monz/pg_monz/releases/tag/2.1
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 ,
Postgresql has the following three ways to set the primary key increment, the following look at the same point and different points.--Method OneCREATE TABLE Test_a(ID Serial,Name character varying (128),Constraint pk_test_a_id primary key
PostgreSQL Basic Command operation:Login database:[Email protected] ~]$ psql-utestwjw-h 127.0.0.1-dpostgres-p 36985Password for user testwjw:Psql.bin (9.5.9)Type ' help ' for help.Postgres=>To switch databases:Postgres=> \c TESTDB1Connected to
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
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
1. Create a master tableCREATE TABLE Part_tab (c1 int, c2 int,name varchar) PARTITION by RANGE (C1);2. Create sub-partition tableCREATE TABLE part1 PARTITION of Part_tab for VALUES from (0) to (100);CREATE TABLE part2 PARTITION of Part_tab for
Originally used is the official installation package, but the installation package will create postgre this user, in the login interface look a bit uncomfortable, search for half a day unexpectedly did not find how to compile the installation under
CREATE OR REPLACE view_nameAsQueryDROP VIEW[IFEXISTS]view_name;a complex query:SELECT cu.customer_id as ID,? ??? text | | " : text | | (cu.last_name):: Span style= "Font-family:times New Roman" >text ) as name ???? a.address,???
PostgreSQL solves the tinyint data type problem in a system database, creating the data types that you need:CREATE DOMAIN tinyintAs smallintCONSTRAINT tinyint_check Check (value >= 0 and value ALTER DOMAIN tinyintOWNER to Postgres;COMMENT on DOMAIN
To back up the database:pg_dump-h localhost-u root demo02 >/home/arno/dumps/demo02.bakTo recover a database:psql-h localhost-u root-d Demo Backup table:pg_dump-h localhost-u root demo02-t books >/home/arno/dumps/books.bakRecovery table:psql-h
So far, you have mastered a certain theory. Because life is not only made up of theories (it can be equally important), it is time to delve into practical work.The goal of this chapter is to let you know how to recover data to a given point in time.
Simple descriptionPath The code is as follows:Copy code /Var/lib/postgresql/9.3/View versionPsql -- version Create UserExample: create a yy user with the password yy, create a blogbase database, and grant all permissions to the yy user The
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.