-- 查询所有的 schema select schema_name from information_schema.schemata; select nspname from pg_catalog.pg_namespace;
权限
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
--- 创建 Read-Only 用户 GRANTCONNECTON DATABASE [db_name] TO [user_name]; GRANT USAGE ON SCHEMA public TO [user_name]; -- special table GRANTSELECTON [table_name] TO [user_name]; -- all tables GRANTSELECTONALL TABLES IN SCHEMA public TO [user_name]; -- grant access to the new tables automatically ALTERDEFAULT PRIVILEGES IN SCHEMA public GRANTSELECTON TABLES TO [user_name];
-- 创建正常用户 CREATEUSER [user_name] WITH PASSWORD 'xxxxxxx'; -- only public schema GRANTALL PRIVILEGES ON DATABASE [db_name] TO [user_name]; GRANTALL PRIVILEGES ONALL TABLES IN SCHEMA public TO [use_rname];
### psql sql ### pg_dump -h [host] -U [user_name] [db_name] > mydb_backup.sql psql -h host -d mydb -U myuser -p 5432 -a -q -f mydb_backup.sql -h PostgreSQL server IP address -d database name -U user name -p port which PostgreSQL server is listening on -f path to SQL script -a all echo -q quiet -f file
// complete (all db and objects) pg_dumpall -U myuser -h 67.8.78.10 --clean --file=backup.dump // restore from pg_dumpall --clean psql -f backup.dump postgres #it doesn't matter which db you select here