Escriu per cercar…

Basic

PostgreSQL

Introduction

PostgreSQL is a powerful, open source object-relational database system.

If you don’t know how an SQL database works, start with the activities in Sqlite.

Docker

Start a Linux virtual machine with Windows Subsystem for Linux (WSL).

Install docker as explained in Docker.

Create a new container running postgres:

shell
docker run -d --name postgres --restart=always -p 5432:5432 -e POSTGRES_PASSWORD=password -e POSTGRES_USER=postgres postgres:18

psql

psql is a shell for PostgreSQL that lets you write queries interactively, send them to PostgreSQL, and view the results.

Create a new terminal session in the container:

shell
docker exec -it postgres bash

Start a session with the user postgres:

shell
psql -U postgres

A Postgres server can manage several databases at the same time.

Use the command \l (or \list) to see all databases defined on the server,

postgres=# \l
                                                List of databases
   Name    |  Owner   | Encoding | Locale Provider | Collate | Ctype | Locale | ICU Rules |   Access privileges
-----------+----------+----------+-----------------+---------+-------+--------+-----------+-----------------------
 postgres  | postgres | UTF8     | libc            | C       | en    |        |           |
 template0 | postgres | UTF8     | libc            | C       | en    |        |           | =c/postgres          +
           |          |          |                 |         |       |        |           | postgres=CTc/postgres
 template1 | postgres | UTF8     | libc            | C       | en    |        |           | =c/postgres          +
           |          |          |                 |         |       |        |           | postgres=CTc/postgres
(3 rows)

Estàs llegint una vista prèvia.

Inicia sessió amb Google per llegir la pàgina completa.

Inicia sessió amb Google

Amb qualsevol compte de Google. Només et demanarem que acceptis les condicions del servei.