postgresql
https://postgresql.org/
https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7.6-x86_64/
https://www.postgresql.org/docs/current/tutorial.html
install postgresql on redhat family https://www.postgresql.org/download/linux/redhat/
https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
rpm -qpl pgdg-redhat-repo-latest.noarch.rpm
yum install pgdg-redhat-repo-latest.noarch.rpm
yum install postgresql96
yum install postgresql96-server
/usr/pgsql-9.6/bin/postgresql96-setup initdb
systemctl enable postgresql-9.6
systemctl start postgresql-9.6
https://yum.postgresql.org/rpmchart.php
[root@node3 ~]# sudo -i -u postgres psql -l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
mydb | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(4 rows)
[root@node3 ~]#
http://www.postgres.cn/docs/9.6/tutorial-table.html
sudo -i -u postgres psql -c "\d" mydb
sudo -i -u postgres psql -c "SELECT version();" mydb
sudo -i -u postgres psql -c "SELECT version();" mydb
SELECT current_date;
SELECT 2 + 2;
显示所有表
sudo -i -u postgres psql -c "\dt" mydb
[root@node3 ~]# sudo -i -u postgres psql -c "\dt" mydb
[root@node3 ~]# sudo -i -u postgres psql -c "\dt" mydb
List of relations
Schema | Name | Type | Owner
--------+---------+-------+----------
public | cities | table | postgres
public | weather | table | postgres
(2 rows)
sudo -i -u postgres psql -c "select * from weather;" mydb
[root@node3 ~]# sudo -i -u postgres psql -c "select * from weather;" mydb
city | temp_lo | temp_hi | prcp | date
---------------+---------+---------+------+------------
San Francisco | 46 | 50 | 0.25 | 1994-11-27
San Francisco | 43 | 57 | 0 | 1994-11-29
Hayward | 37 | 54 | | 1994-11-29
(3 rows)