2608

Ubuntu22.04安装postgresql-16

添加软件源

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

添加密钥签名

wget -qO- https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo tee /etc/apt/trusted.gpg.d/pgdg.asc &>/dev/null
504

PostgreSQL操作备忘

允许 test 账号访问 demo 库

GRANT CONNECT ON DATABASE test TO demo;

禁止 test 账户访问所有public库

REVOKE ALL ON DATABASE test FROM PUBLIC;

同时截断表

BEGIN;
TRUNCATE TABLE "Table1" CASCADE;
TRUNCATE TABLE "Table2" CASCADE;
TRUNCATE TABLE "Table3" CASCADE;
COMMIT;