Editing PostgreSQL
Jump to navigation
Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 22: | Line 22: | ||
postgres | postgres | ||
− | + | == Configuration files == | |
− | + | * <code>/etc/postgresql/10/main/[[postgresql.conf]]</code> | |
− | + | * <code>/etc/postgresql/10/main/[[pg_hba.conf]]</code> (PostgreSQL Client Authentication Configuration File) | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | == Configuration | ||
− | * <code>/etc/postgresql/ | ||
− | * <code>/etc/postgresql/ | ||
# "local" is for Unix domain socket connections only | # "local" is for Unix domain socket connections only | ||
local all all md5 | local all all md5 | ||
− | |||
− | |||
== [[PostgreSQL logs]] == | == [[PostgreSQL logs]] == | ||
− | *<code>[[/var/log | + | *<code>[[/var/log/]]postgresql</code> |
== Basic Commands== | == Basic Commands== | ||
Line 48: | Line 37: | ||
* Connect to a PostgreSQL database: <code>[[psql]] -h localhost -U postgres -d somedb</code><ref>http://postgresguide.com/utilities/psql.html</ref> | * Connect to a PostgreSQL database: <code>[[psql]] -h localhost -U postgres -d somedb</code><ref>http://postgresguide.com/utilities/psql.html</ref> | ||
* Connect to a PostgreSQL database with a timeout of 5 seconds: <code>env PGCONNECT_TIMEOUT=5 psql -h localhost -U postgres -d somedb</code><ref>http://postgresguide.com/utilities/psql.html</ref> | * Connect to a PostgreSQL database with a timeout of 5 seconds: <code>env PGCONNECT_TIMEOUT=5 psql -h localhost -U postgres -d somedb</code><ref>http://postgresguide.com/utilities/psql.html</ref> | ||
− | * [[Show databases]]: | + | * [[Show databases]]: <code>SELECT datname FROM pg_database WHERE datistemplate = false;</code> |
− | |||
− | |||
* Show tables: <code>\dt</code> or <code>SELECT * FROM [[pg_catalog]].pg_tables;</code><ref>https://stackoverflow.com/questions/769683/show-tables-in-postgresql</ref> | * Show tables: <code>\dt</code> or <code>SELECT * FROM [[pg_catalog]].pg_tables;</code><ref>https://stackoverflow.com/questions/769683/show-tables-in-postgresql</ref> | ||
− | * [[Show users]]: <code> | + | * [[Show users]]: <code>\du</code> |
* Drop DB: <code>[[dropdb]] DB_NAME</code> | * Drop DB: <code>[[dropdb]] DB_NAME</code> | ||
Line 59: | Line 46: | ||
* Show version: <code>[[SELECT version();]]</code> | * Show version: <code>[[SELECT version();]]</code> | ||
− | * Create backup: use <code>pg_dump</code> <ref>https://www.postgresql.org/docs/current/static/app-pgdump.html</ref> and <code> | + | * Create backup: use <code>pg_dump</code> <ref>https://www.postgresql.org/docs/current/static/app-pgdump.html</ref> and <code>~/.pgpass</code> file for automating login. |
* Create user: | * Create user: | ||
** <code>[[create user]] <username></code> | ** <code>[[create user]] <username></code> | ||
Line 68: | Line 55: | ||
− | * <code> | + | * <code>[[systemctl status postgresql]]</code> |
+ | * <code>[[systemctl stop]] postgresql</code> | ||
+ | * <code>[[systemctl start]] postgresql</code> | ||
− | + | * <code>[[\l]]</code> | |
− | * <code>[[\l]] | + | * <code>[[\du]]</code> |
+ | * <code>[[\dt]]</code> | ||
+ | * <code>[[\c]]</code> | ||
== Processs == | == Processs == | ||
* [[wal]] writer process | * [[wal]] writer process | ||
+ | |||
== Related terms == | == Related terms == | ||
− | * [[ | + | * <code>[[/var/lib/postgresql/]]</code> |
* <code>[[pg_upgradecluster]]</code> | * <code>[[pg_upgradecluster]]</code> | ||
* [[Adminer]] | * [[Adminer]] | ||
+ | * {{TOC operation databases}} | ||
+ | * [[ALTER DATABASE]] | ||
* [[Amazon Redshift]] | * [[Amazon Redshift]] | ||
− | + | * [[PostgreSQL statistics collector]]: <code>[[pg_stat]]*</code> | |
− | + | * [[MVCC]] | |
− | * | + | * [[Master]] user, [[Index (PostgreSQL)]] |
− | * [[ | ||
− | |||
* [[Greenplum]] | * [[Greenplum]] | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Activities == | == Activities == | ||
Line 105: | Line 85: | ||
== See also == | == See also == | ||
+ | * {{SQL}} | ||
+ | * {{PostgreSQL}} | ||
* [[Patroni]] [[HA]] solution for PostgreSQL that requires <code>[[etcd]]</code>, <code>[[Zookeeper]]</code>, or <code>[[Consul]]</code> | * [[Patroni]] [[HA]] solution for PostgreSQL that requires <code>[[etcd]]</code>, <code>[[Zookeeper]]</code>, or <code>[[Consul]]</code> | ||
− | * {{ | + | * {{DBs}} |
− | |||
[[Category:PostgreSQL]] | [[Category:PostgreSQL]] |
Advertising: