PostgreSQL 数据库导入导出操作
PostgreSQL 数据库操作简要说明 PostgreSQL数据库版本 psql --version 一、数据库备份 1、备份数据库结构 su - postgres 2、备份数据库数据 su - postgres 3、备份数据库结构和数据 su - postgres 4、备份数据库中指定表结构 pg_dump -Fc -s -t citycode -f citycode_schema.sql testdb 5、备份数据库中指定表数据 pg_dump -Fc -a -t citycode -f citycode_data.sql testdb .6、备份数据库中指定表(结构和数据) pg_dump -Fc -t citycode -f citycode_schemadata.sql testdb 二、删除数据库 su - postgres dropdb testdb 三、恢复数据库 1、创建新数据库testdb su - postgres createdb testdb;
su - postgres pg_restore -s -d testdb testdbschema.sql 3、恢复数据库数据(only data) su - postgres pg_restore -a -d testdb testdbdata.sql 4、恢复数据库结构和数据(schema and data) su - postgres pg_restore -d testdb testdbschemadata.sql 5、指定表数据恢复 1)删除表 psql testdb DROP TABLE citycode; 2)恢复表结构 pg_restore -s -t citycode -d testdb citycode_schema.sql 3)恢复表数据 pg_restore -a -t citycode -d testdb citycode_data.sql 4)恢复表(结构和数据) pg_restore -t citycode -d testdb citycode_schemadata.sql 以上备份恢复相关操作可用于静态(无数据增长)数据库。 重要提示:pg_restore 可用来恢复pg_dump命令以 (FcFt)格式备份的数据文件。执行pg_dump备份命令时若无此格式参数声明,pg_restore 恢复时可能出现错误提示“pg_restore: [archiver] input file does not appear to be a valid archive”。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- Exchange 2010与Exchange Online混合部署PART 5:
- Swift学习资料汇总
- 带有p的点表示法,用于swift中的十六进制数字文字
- ruby-on-rails – 为Rails中安装的sinatra应用程
- Oracle ASM数据库故障数据恢复解决方案
- Cocos2d-x 3.11.1 Mac 编译Android Studio
- objective-c – 在Swift中使用Obj-C完成块
- 使用Ruby中的Net :: HTTP创建带有标头信息的HTTP
- .net – 无法在LINQ中强制转换’WhereSelectList
- Qt assistant.exe Cannot load sqlite database