Postgres 常用命令
来源:互联网 发布:java实现图片上传 编辑:程序博客网 时间:2024/05/16 19:48
本地数据库拷贝:
windows:createdb -T originalDb targetDb -U postgres
linux:su postgres
createdb -T originalDb targetDb
异地数据库拷贝(参考):
1)将数据库拷生成
$ pg_dump -U postgres -O <dbname> > <dbname>.sql
如:$ pg_dump -U postgres -O postgres > /root/mydbBackup.sql
2)将生成的文件拷贝至目标机器
3)如果同名数据库已经存在,删除操作为:
$ psql -U postgres -c "drop database <dbname>;"
如:$ psql -U postgres -c "drop database mydb2;"
4)数据文件恢复必须在已经创建好的数据库的基础上
$ psql -U postgres -c "create database <dbname> with owner <owname> encoding = 'UNICODE';"
如:$ psql -U postgres -c "create database mydb2 with owner postgres encoding = 'UNICODE';"
5)恢复数据库:
$ psql -U <owname> -d <dbname> -f <dbname>.sql
如:$ psql -U postgres -d mydb2 -f C:/mydbBackup.sql
联合更新
update table1 set field1 = (select field1 from table1_copy where table1.parent_id = table1_copy.id)
导入数据
psql dbname username < filename.sql
psql pgdb postgres < /root/sqlscript/pgdb-data.sql
- Postgres 常用命令
- Postgres常用命令
- postgres常用命令
- Postgres常用命令总结
- postgres数据库常用命令
- 整理使用postgres需要设置和常用命令
- postgres
- postgres
- postgres
- postgres
- Postgres
- postgres performance
- Postgres触发器
- Postgres 管理
- postgres简介
- postgres commands
- postgres 数组
- Postgres 指南
- java LinkedList分析(ZZ)
- CSS下拉菜单在IE6需要注意的问题
- 图算法总结
- ARM汇编伪指令介绍(1)
- 第一次问题
- Postgres 常用命令
- ARM汇编伪指令介绍(2)
- word实用技巧
- java内部类总结
- 俞敏洪在北大2008开学典礼的报告
- Linux下面的类红警游戏
- xml节点的删除出错
- ANT_JMETER之生成的测试报告
- 做饭的小技巧集锦