diff --git a/wiki/docker/postgres.md b/wiki/docker/postgres.md index 4bae69a..7c91452 100644 --- a/wiki/docker/postgres.md +++ b/wiki/docker/postgres.md @@ -1,6 +1,6 @@ # postgres -This is a [Docker](/wiki/docker.md) container for a postgresql database. +This is a [Docker](/wiki/docker.md) container for a [postgresql database](/wiki/postgresql.md). The official container and documentation was made by [Postgres](https://hub.docker.com/_/postgres). The Docker container is mainly used in combination with other containers. diff --git a/wiki/postgresql.md b/wiki/postgresql.md new file mode 100644 index 0000000..b4d5be8 --- /dev/null +++ b/wiki/postgresql.md @@ -0,0 +1,59 @@ +# PostgreSQL + +[PostgreSQL](https://www.postgresql.org/) is a free and open-source relational database managment +system. + +## Setup + +The software can be setup via [Docker](/wiki/docker.md) with the +[postgres image](/wiki/docker/postgres.md). + +## Usage + +This section addresses the usage of PostgreSQL. + +### Basic Usage + +This section describes the basic usage and is based on a +[blog entry on Neon](https://neon.com/postgresql/postgresql-administration/postgresql-show-tables). + +The following command can be used to connect to the database and is needed to be run first. +`` is the username and `` the name of the database set up for the database. + +```sh +psql -U -d +``` + +Alternatively the previous command can be run without the `-d` flag and the following command can +be run afterwards to change the current database. + +```sh +\c +``` + +Afterwards the following command can be used to show all tables in the database. + +```sh +\dt +``` + +By appending a `+` additional information can be shown + +```sh +\dt+ +``` + +Similar to this the following command can be used to show details of a specific table ``. + +```sh +\d
+``` + +Here a `+` can also be appended to gain more information. + +```sh +\d+
+``` + +Finally and most importantly classic SQL statements - for example `SELECT`-statements - can be used +too when being logged in to a database.