
30.在 linux 中执行计划任务
通过 crontab 执行
su root -c "psql -p 5433 -U developer MTPS -c'select test()'"
developer 用户的密码存储于环境变量 PGPASSWORD 中。
31.查询表是否存在
select * from pg_statio_user_tables where relname='你的表名';
32.为用户复制 SCHEMA 权限
grant all on SCHEMA 作用域名称 to 用户名称
33.整个数据库导出
pg_dumpall -D -p 端口号 -h 服务器 IP -U postgres(用户名) >
/home/xiaop/all.bak
34.数据库备份恢复
psql -h 192.168.0.48 -p 5433 -U postgres
35.当前日期函数
current_date
36.返回第十条开始的 5 条记录
select * from tabname limit 5 offset 10;
37.为用户赋模式权限
Grant on schema developer to UDataHouse
38.将字符转换为日期时间
select to_timestamp('2010-10-21 12:31:22', 'YYYY-MM-DD hh24:mi:ss')
39.数据库备份
pg_dumpall -h 192.168.0.4 -p 5433 -U
postgres >/DataBack/Postgresql2010012201.dmp
如 8.1 以后多次输入密码
40.\dn
查看 schema
41.删除 schema
drop schema _clustertest cascade;
42.导出表
./pg_dump -p 端口号 -U 用户 -t 表名称 -f 备份文件位置 数据库 ;
43.字符串操作函数
select distinct(split_part(ip,'.',1)||'.'||split_part(ip,'.',2)) from t_t_userip order
by (split_part(ip,'.',1)||'.'||split_part(ip,'.',2));
44.删除表主键
alter table 表名 drop CONSTRAINT 主键名称;
相关文档
评论