Difference between revisions of "PostgreSQL"

From Dogtag
Jump to: navigation, search
m (Connecting to Database)
m (Listing Tables)
Line 32: Line 32:
 
<pre>
 
<pre>
 
$ psql postgres://<username>:<password>@<hostname>:<port>/<database>
 
$ psql postgres://<username>:<password>@<hostname>:<port>/<database>
 +
</pre>
 +
 +
= Listing Databases =
 +
 +
<pre>
 +
psql> \l
 
</pre>
 
</pre>
  

Revision as of 21:56, 13 January 2020

Installation

To install PostgreSQL client:

$ dnf install postgresql

To install PostgreSQL server:

$ dnf install postgresql-server

Initializing Database

$ postgresql-setup --initdb --unit postgresql
$ systemctl start postgresql

Connecting to Database

To connect to a local database:

$ sudo -u postgres psql

To connect to a remote database:

$ psql postgres://<username>:<password>@<hostname>:<port>/<database>

Listing Databases

psql> \l

Listing Tables

psql> \dt

Describing a Table

psql> \d <name>

See Also