pg psql命令
linux下使用psql命令操作数据库
下面主要用到了insert into ,pg_dump , pg_restore 命令
按步骤走
su postgres 切换指定用户
pg_restore -d mydb /mnt/mydb.backup mydb指定数据库 mydb.backup 恢复的文件
ALTER TABLE table1 RENAME TO table2; 给表重命名 把表1改成表2
insert into table1 select name,age,height from student where add_time <'2013-10-01'; insert into 的使用 table1必须存在
select * into table1 from student where name like '%杉%'; select into的使用 talbe1必须不存在 把查询到的数据插入到table1
psql -d xxx xxx指定数据库
\dt 查看当前数据库非系统表
\c xx 切换指定db;
select * from student; 注意一定带上分号 ";" 表示命令的结束
\q 退出psql模式
备份指定表
pg_dump --host localhost --port 5432 --username "sqluser" --format custom --blobs --encoding UTF8 --ignore-version --verbose 数据库 -t 表 --file /mnt/11.backup
恢复指定表
pg_restore -d 数据库 /mnt/11.backup
pg psql命令的更多相关文章
- psql 命令总结
1 登录数据库 Connection options: -h, --host=HOSTNAME database server host or socket directory (default: & ...
- psql命令
原文:http://blog.csdn.net/smstong/article/details/17138355 psql# shell 环境下,查看当前所在的数据库的命令是: select cur ...
- 跟我一起读postgresql源码(一)——psql命令
进公司以来做的都是postgresql相关的东西,每次都是测试.修改边边角角的东西,这样感觉只能留在表面,不能深入了解这个开源数据库的精髓,遂想着看看postgresql的源码,以加深对数据库的理解, ...
- psql命令行快速参考
psql的命令语法是: psql [options] [dbname [username]] psql命令行选项以及它们的意思在表1-1中列出.使用以下命令可以看到psql完整的选项列表: $ psq ...
- psql 命令行使用
如果觉得直接打开数据库修改繁琐,那么使用终端命令行是方便而又高大上的.下面来看看有哪些命令行: 说明:如果是正式的服务器则需要进行一个操作在执行下面的命令 ssh name @主机地址 -- name ...
- windows下怎么打开psql命令
你是直接执行的psql.exe吧? 那么需要加入数据库位置等一些参数的.Windows系统下,PostgreSQL有提供一个命令行脚本runsql.bat, 在安装目录的scripts文件夹中,一般是 ...
- postgresql的psql命令
1:不进入数据库而执行SQL命令,用参数-c 2:把SQL命令保存在一个外部文件中,用 -f 参数导入并执行 a1.txt文件内容 select * from student; 在shell中用如下命 ...
- PSQL命令小结
经常使用psql查询数据,现在总结几个常用的命令参数,供以后参考 -h 数据库地址 -U 数据库用户名 -t 不打印字段等信息 -c 执行的SQL语句 -s 单步执行,就是执行的时 ...
- 查看,检查,修复pg的命令
标签(空格分隔): ceph,ceph运维,pg 如果集群状态是HEALTH_ERR 并且有pgs inconsistent,需要进行如下操作: 1. 通过下面的命令查看哪些pg状态不一致: # ce ...
随机推荐
- 无线Ad-hoc网络的关键技术之路由(转)
无线Ad-hoc网络的关键技术之路由http://network.51cto.com/art/201003/189719.htm
- 消除ComponentOne(C1StudioNet_2013v2) 的注册提示
以后大家如果遇到还有提示,在License文件里添加:C1.Win.C1Command.C1OutBar, C1.Win.C1Command.4, Version=4.0.20132.19568, ...
- UVA 11076 Add Again 计算对答案的贡献+组合数学
A pair of numbers has a unique LCM but a single number can be the LCM of more than one possiblepairs ...
- Linux下查看进程和线程
在linux中查看线程数的三种方法 1.top -H 手册中说:-H : Threads toggle 加上这个选项启动top,top一行显示一个线程.否则,它一行显示一个进程. 2.ps xH 手册 ...
- 【转】RESTful Web Services初探
近几年,RESTful Web Services渐渐开始流行,大量用于解决异构系统间的通信问题.很多网站和应用提供的API,都是基于RESTful风格的Web Services,比较著名的包括Twit ...
- ColorDescriptor software v4.0 一个提取颜色特征描述子的软件包
ColorDescriptor software v4.0 Created by Koen van de Sande, (c) University of Amsterdam Note: Any co ...
- ajax练习习题一弹窗查看
显示页面 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3 ...
- NDK(0)简介
AndroidNDK Android NDK 是在SDK前面又加上了“原生”二字,即Native Development Kit,因此又被Google称为“NDK”. 众所周知,Android程序运行 ...
- Codeforces Round #362 (Div. 2) A.B.C
A. Pineapple Incident time limit per test 1 second memory limit per test 256 megabytes input standar ...
- js 监听监键盘动作
浏览器firefoxfunctionoperamicrosoftmozilla 转载自:http://geelong.javaeye.com/blog/810054 主要分四个部分第一部分:浏览器的按 ...