Difference between revisions of "PostgreSQL"

From wikieduonline
Jump to navigation Jump to search
Line 1: Line 1:
 
{{Draft}}
 
{{Draft}}
 
[[wikipedia:PostgreSQL]]
 
[[wikipedia:PostgreSQL]]
 +
 +
 +
 +
'''[[w:PostgreSQL|PostgreSQL]]''', often simply '''Postgres''', is an [[w:object-relational database management system]] (ORDBMS). PostgreSQL is [[w:ACID]]-compliant and [[w:Transaction processing|transactional]]. PostgreSQL has updatable [w:[View (SQL)|views]] and [[w:materialized view]]s, [[w:Database trigger|triggers]], [[w:foreign key]]s; supports functions and stored procedures, and other expandability
 +
 +
== Installing PostgreSQL ==
 +
=== MacOS ===
 +
*<code>[[brew]] install postgres</code>
 +
=== 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.
 +
 +
== Basic Commands==
 +
Binaries: <code>psql</code>, <code>pg_dump</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>
 +
* 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>
 +
* Describe ''employees'' table: <code>\d employees</code>
 +
* 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.
 +
 +
== Releases (yearly) ==
 +
PostgreSQL release a new version approximately every year around October: https://en.wikipedia.org/wiki/PostgreSQL#Release_history
 +
* October 2018 PostgreSQL 11.0 https://www.postgresql.org/about/news/1894/, https://www.postgresql.org/docs/release/11.0/
 +
* October 2019 PostgreSQL 12.0 https://www.postgresql.org/about/news/1976/, https://www.postgresql.org/docs/release/12.0/
  
  
Line 10: Line 35:
  
 
[[Category:Databases]]
 
[[Category:Databases]]
 +
 +
{{CC license}}
 +
Source: wikiversity

Revision as of 15:52, 12 January 2020

This article is a Draft. Help us to complete it.

wikipedia:PostgreSQL


PostgreSQL, often simply Postgres, is an w:object-relational database management system (ORDBMS). PostgreSQL is w:ACID-compliant and transactional. PostgreSQL has updatable [w:[View (SQL)|views]] and w:materialized views, triggers, w:foreign keys; supports functions and stored procedures, and other expandability

Installing PostgreSQL

MacOS

  • brew install postgres

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 pkg command in DragonFlyBSD or apt 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

Binaries: psql, pg_dump.

  • Connect to a PostgreSQL database: psql -h localhost -U postgres -d somedb[1]
  • Connect to a PostgreSQL database with a timeout of 5 seconds: env PGCONNECT_TIMEOUT=5 psql -h localhost -U postgres -d somedb[2]
  • Show tables: \dt or SELECT * FROM pg_catalog.pg_tables;[3]
  • Describe employees table: \d employees
  • Show/List schemas: select nspname from pg_catalog.pg_namespace;[4]
  • Create backup: use pg_dump [5] and ~/.pgpass file for automating login.

Releases (yearly)

PostgreSQL release a new version approximately every year around October: https://en.wikipedia.org/wiki/PostgreSQL#Release_history


See also

Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy.

Source: wikiversity

Advertising: