Postgres – tabele

Tworzenie tabeli

CREATE TABLE users (
    id              serial  primary key,
    name            varchar(80),
    age             int,           -- how many years
    temp_hi         int,           -- high temperature
    prcp            real,          -- precipitation
    date            date
);
-- <komentarz>

DESC users – struktura tabeli users

\d+ users

Typy

int, smallint, real, double precision, char(N), varchar(N), date, time, timestamp, interval

Wstawianie danych – kopiowanie z pliku do tabeli

COPY users FROM '/home/joe/users.txt';

Postgres – komendy

Poziom klienta – terminala psql

\l[+]      - lista baz danych


\dt[+]      - lista tabel
\dp         - tabele, widoki, uprawnienia

\du     - użytkownicy / role

DESC users – struktura tabeli users

\d+ users
\dT[+]      - schema
\dO[+]      - collations
help \?
\q      - WYJŚCIE
exit
select version();

PostgreSQL 13.20 (Debian 13.20-0+deb11u1) on x86_64-pc-linux-gnu, compiled by gcc