-- Bez strefy czasowej ALTER TABLE invoices ADD COLUMN modified TIMESTAMP DEFAULT CURRENT_TIMESTAMP;
Czytaj dalej Kolumna modified – aktualizowana przy każdej zmianie rekordu
-- Bez strefy czasowej ALTER TABLE invoices ADD COLUMN modified TIMESTAMP DEFAULT CURRENT_TIMESTAMP;
Czytaj dalej Kolumna modified – aktualizowana przy każdej zmianie rekordu
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';
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
Jako użytkownik postgres (su – postgres)
# shell createuser --pwprompt username # pyta o hasło
Pliki konfiguracyjne
# ls /etc/postgresql/13/main/ conf.d environment pg_ctl.conf pg_hba.conf pg_ident.conf postgresql.conf start.conf
Restart serwera Postgresql
systemctl restart postgresql
apt install postgresql