Function
Return type
Description
Example
To_char(Timestamp,Text)
Text
Converts a timestamp to a string.
To_char (current_timestamp, 'hh12: MI: ss ')
To_char(Interval,Text)
Text
Convert the time interval
Actually, ":" Calls the CAST function. Which fields can be converted into one another?You only need to study the cast function to obtain the answer to this question. The cast function information is managed in the pg_cast table of the system.The
I. Type conversionPostgres type conversion: Usually: used for type conversion, timestamp to date is used moreSelect now (): DateSelect now (): varcharExample 1: varchar of a date is calculated as date.Select '2017-11-15 16:15:56. 2012 + 08':
References (PL/pgsql official documentation): http://www.postgresql.org/docs/9.3/static/plpgsql.htmlCreate or replace function creatdata2 () returns boolean as $ body $ declare II integer; begin II: = 1; for II in 1 .. 10000000 loop insert into
The default value is public,To switch: Set search_path to '_ schema, public ';In this way, the query is convenient, so you don't have to worry about schema. Table.However, the problem is:Index of the table to be queried,The index definition of the
Hibernate can be used to implement cross-database to a certain extent, but sometimes there are still some problems, even if it does not involve the advanced features of the database. recently, a project was developed in windwos + SQL Server2000,
1, development we often encounter data in the database there is a small-level parent-child relationship, such as the country's provincial and municipal information, or a company's department information.
If we use recursion to query the data
CREATE OR REPLACE FUNCTION get_user (Test integer)
RETURNS setof test as $BODY $
DECLARE R Record;
BEGIN
for R in SELECT * from Test where id=$1 LOOP
RETURN NEXT R;
END LOOP;
If not found then
For R in with a (ID, a, c) as (
INSERT into test values (
A development environment has a number of sites, need to use a different session, a lot of solutions. But this time also tall on a, with the data inventory, convenient later expansion. The first part of the database --drop table php_sessioncreate
1. Export the result of the query statement to the file (you must execute the statement after switching to the database via Psql):\copy (select Id,mk,bth from basic where state= ' 0 ') to/tmp/test.csv2. Export the data directly to the file via the
, when you search for no results, you can query for spelling errors and use the results provided by the query to give the user some advice. If the data comes from informal communication, such as a social network, your data may contain spelling mistakes. You can get a good result by appending a similar semantics to your tsquery.
"Super Fuzzy searching on PostgreSQL" is a good reference article about using the three-letter group for spelling errors and search
Main Library ConfigurationPg_hba.confHost replication All 10.2.0.0/0 TrustPostgresql.conflisten_addresses = ' * ' max_wal_senders = 5wal_level = Hot_standbyRestarting the main libraryConfigure from LibraryInstallationInstall with Yum (source http://yum.postgresql.org/)Yum Install https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/ Pgdg-centos95-9.5-2.noarch.rpmyum Install Postgresql95-server Postgresql95-contribGenerate base Backup (primary database IP 10.2.0.14)Pg_basebackup
Label:First, the environment$ psql--version
psql (PostgreSQL) 9.4.4 As we all know, superuser privileges are too large for the security of the database, for non-administrator accounts, you need to create a normal user. Second, the grammar$psql psql (9.4.4) type "Help" forhelp.
postgres=#\hcreaterole Command:createrole Description:defineanewdatabaserole syntax:createrolename[ [with]option[...]] Whereoptioncanbe: superuser|nosuperuser |CREATEDB| Nocre
Label:Reference: https://hub.docker.com/_/postgres/ https://docs.docker.com/engine/installation/debian/ Using Docker for multi-instance installation is simpler, more convenient, and better isolated than the source code. Installing Docker
Update the installation source
sudo apt-key adv--keyserver HKP://p80.pool.sks-keyservers.net:80--recv-keys 58118e89f3a912897c070adbf76221572c52609d
sudotouch /etc/apt/sources.list.d/ Docker.list
su
Description:in order to standardize the management of intranet server user password information, a set of CMDB system is deployed to manage it. First, environmental needs:For an introduction to the installation environment, a detailed description of the CMDB installation manual is also presented here:Hardware Environment :
CPU generally can
Memory Minimum is 2G
Minimum storage space is 60G
Software Requirements :
Operating system: preferably Linux
Database: Aft
First, the environment#配置远程连接su postgres vim/var/lib/pgsql/9.4/data/postgresql.conf Edit configuration file listen_address= ' localhost ' before the comment # removed,And the ' localhost ' should be ' * '; vim/etc/postgresql/8.2/main/pg_hba.conf host all 192.168.1.0/24 password password can be set to Trust/etc/init.d/postgre sql-8.2 Restart Restart Service: There is the Stop start command as well. If a configuration error can cause a restartSecond, th
PostgreSQL is an object-relational database management system (ORDBMS) based on POSTGRES, Version 4.2, developed by the University of California, Berkeley computer department. Many of the concepts pioneered by Postgres appear in the commercial database for a long time. PostgreSQL is an open source successor to the original Berkeley code. It supports most of the SQL standards and offers many other modern fea
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.