Postgresql 常用操作

表所有者一括变更

select 'alter table public.'|| tablename ||' owner to appuser;' from pg_tables where tableowner='postgres' and schemaname='public';

改变操作数据库

HBS=# c TEST;

查看所有表

HCS=# dt;

查看表结构

HCS=# d tablename;

批量执行SQL

psql -d db1 -U userA -f E://p/xxx.sql

 本地数据库迁移到RDS阿里云数据库

1,本地数据库备份

pg_dump -U William -h localhost -p 3433 -d pg001 -f pg001.sql

2,数据库迁移

psql -U username -h hostname -d desintationdb -p port -f dumpfilename.sql
原文地址:https://www.cnblogs.com/lixiaobin/p/Postgresql.html