tags: postgresql, cheatsheet
su -l postgres -c psql
CREATE USER xyu WITH PASSWORD 'str0ngp0ssw0rd';
ALTER USER xyu WITH PASSWORD 'cykableat';
CREATE DATABASE nextcloud WITH OWNER xyu;
vi ~/.pgpass
Add index on field:
ALTER TABLE stat ADD INDEX (hostname);
ALTER TABLE stat ADD INDEX (created);
Add index on two fields:
ALTER TABLE stat ADD INDEX `hostname_created_index`(`hostname`, `created`);
SHOW INDEX FROM `stat`;
DROP INDEX hostname ON stat;
Add to /etc/postgresql/VERSION/main/postgresql.conf /etc/postgresql/postgresql.conf
log_statement = 'all'
https://tableplus.com/blog/2018/04/postgresql-how-to-grant-access-to-users.html