![postgreSQL数据库里导入导出的sql语句是什么?,第1张 postgreSQL数据库里导入导出的sql语句是什么?,第1张](/aiimages/postgreSQL%E6%95%B0%E6%8D%AE%E5%BA%93%E9%87%8C%E5%AF%BC%E5%85%A5%E5%AF%BC%E5%87%BA%E7%9A%84sql%E8%AF%AD%E5%8F%A5%E6%98%AF%E4%BB%80%E4%B9%88%EF%BC%9F.png)
Postgresql
数据的导入和导出,以及copy命令介绍\x0d\x0a\x0d\x0a如何导出PostgreSQL
数据库中的数据:\x0d\x0apg_dump -U postgres -f dump.sql mydatabase\x0d\x0a具体某个表\x0d\x0apg_dump -U postgres -t mytable -f dump.sql mydatabase\x0d\x0a\x0d\x0a导入数据时首先创建数据库再用psql导入:\x0d\x0acreatedb newdatabase\x0d\x0apsql -d newdatabase -U postgres -f dump.sql\x0d\x0a\x0d\x0a把数据按照自己所想的方式导出,强大的copy命令:\x0d\x0aecho "copy students to? stdout DELIMITER '|'"|psql school|head\x0d\x0a(students为表名,school为库名,各个字段以|分隔)\x0d\x0aecho 'copy (select * from students order by age limit 10) to stdout' | psql school打开cmd,进入数据库名ql安装路径:
可以使用pg_dump --help命令查看帮助
C:\Program Files\数据库名QL\9.2\bin>pg_dump -h 数据库地址/主机名 -p 端口号 -U postgres --column-inserts -t 表名 -f 导出路径 数据库名
例子:
C:\Program Files\PostgreSQL\9.2\bin>pg_dump -h localhost -p 5432 -U postgres --column-inserts -t table_name -f d://save_sql.sql database_hason
导出整个数据库 pg_dump -h localhost -U postgres(
用户名) 数据库名(缺省时同用户名) >/data/dum.sql 导出某个表 pg_dump -h localhost -U postgres(用户名) 数据库名(缺省时同用户名) -t table(表名) >/data/dum.sql
评论列表(0条)