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 1: | Line 1: | ||
− | [[ | + | |
+ | '''[[PostgreSQL]]''', often simply '''Postgres''', is an [[object-relational database management system]] (ORDBMS). PostgreSQL is [[ACID]]-compliant and [[Transactional]]. PostgreSQL has updatable [[Views]] and [[Materialized view]], [[Triggers]], [[Foreign key]]; supports functions and stored procedures, and other expandability. PostgreSQL listens by default in TCP port 5432. | ||
== Installing PostgreSQL == | == Installing PostgreSQL == | ||
=== MacOS === | === MacOS === | ||
− | * <code>[[brew install postgres]]</code> | + | * <code>[[brew install postgres]]</code> |
* <code>[[brew install libpq]]</code>: <code>[[psql]]</code> and other 28 binaries. | * <code>[[brew install libpq]]</code>: <code>[[psql]]</code> and other 28 binaries. | ||
=== Linux, BSD variants === | === Linux, BSD variants === | ||
The easiest way to install PostgreSQL in these operating systems is to use their respective built-in package managers - for instance, the <code>pkg</code> command in DragonFlyBSD or <code>apt</code> in Debian and its derivatives. Be advised that there will be different variants of PostgreSQL available for install at a given point, specially regarding version numbers and client/server side. You should decide beforehand which version suits your needs for a particular application. Furthermore, you need to make sure that you have sufficient privileges in the system to install software (properly configured sudo/doas access, for example) or your install will fail. | The easiest way to install PostgreSQL in these operating systems is to use their respective built-in package managers - for instance, the <code>pkg</code> command in DragonFlyBSD or <code>apt</code> in Debian and its derivatives. Be advised that there will be different variants of PostgreSQL available for install at a given point, specially regarding version numbers and client/server side. You should decide beforehand which version suits your needs for a particular application. Furthermore, you need to make sure that you have sufficient privileges in the system to install software (properly configured sudo/doas access, for example) or your install will fail. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Basic Commands== | == Basic Commands== | ||
− | Binaries: <code> | + | Binaries: <code>psql</code>, <code>pg_dump</code>. |
− | * Connect to a PostgreSQL database: <code> | + | * 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 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 | ||
− | |||
− | |||
− | |||
* Describe ''employees'' table: <code>\d employees</code> | * Describe ''employees'' table: <code>\d employees</code> | ||
− | * Show/List | + | * Show/List schemas: <code>select nspname from pg_catalog.pg_namespace;</code><ref>https://dba.stackexchange.com/questions/40045/how-do-i-list-all-schemas-in-postgresql</ref> |
− | + | * 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 backup: use <code>pg_dump</code> <ref>https://www.postgresql.org/docs/current/static/app-pgdump.html</ref> and <code> | ||
− | |||
− | |||
− | |||
* <code>[[create database]]</code> | * <code>[[create database]]</code> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Activities == | == Activities == | ||
* [[PostgreSQL parameter tunning]] | * [[PostgreSQL parameter tunning]] | ||
− | |||
== See also == | == See also == | ||
− | |||
− | |||
* {{PostgreSQL}} | * {{PostgreSQL}} | ||
+ | * [[AWS RDS]], [[AWS Redshift]] | ||
+ | * [[Patroni]] [[HA]] solution for PostgreSQL that requires [[etcd]], [[Zookeeper]], or [[Consul]] | ||
+ | * {{DBs}} | ||
− | |||
[[Category:Databases]] | [[Category:Databases]] | ||
{{CC license}} | {{CC license}} | ||
Source: wikiversity | Source: wikiversity |
Advertising: