数据库字符编码问题: -- 查看PostgreSQL数据库服务器端编码: show server_encoding; -- 查看PostgreSQL客户端工具psql编码: show client_encoding; -- 指定Postgresql会话的客户端编码: set client_encoding to 'utf8'; -- 获取当前系统时间(包括时区) 形如:2017-09-07 14:30:07.965671+08 s
中文资料 中文资料 /**gp中的基本sql语法**/ --删除表 drop table testtb; --创建表 CREATE TABLE testtb ( id integer, "name" character varying(2) ) WITH ( OIDS=FALSE ) DISTRIBUTED BY (id); ALTER TABLE testtb OWNER TO gpadmin; --WITH 用来说明表的存储属性,比如表的压缩 --DISTRIBUTED BY 定义
本次测试基与PostgreSQL 10.x版本 创建用户 [postgres@rtm2 data]$ /opt/pgsql-10/bin/createuser rentaomin [postgres@rtm2 data]$ 登陆psql查询创建的用户 postgres=# \du List of roles Role name | Attributes | Member of -----------+------------------------------------------------
1.序列 以自增serial类型主键的序列: alter sequence s_seq restart with 1; #重置序列select currval('tablename_pid_seq');select nextval('tablename_pid_seq');select setval('tablename_pid_seq',1); 2.修改表 --删除约束alter table tablename alter column col drop not null; --添加约束alt
添加表字段 ALTER TABLE public.university ADD COLUMN "Province" character varying(10); COMMENT ON COLUMN public.university."Province" IS '省份'; 删除表字段 ALTER TABLE public.university DROP COLUMN "Province"
--查看数据库 select * from pg_database; --查看表空间 select * from pg_tablespace; --查看语言 select * from pg_language; --查看角色用户 select * from pg_user; select * from pg_shadow; select * from pg_roles; --查看会话进程 select * from pg_stat_activity; --查看表 SELECT * FROM pg
1. 查看当前库sehcma大小,并按schema排序 SELECT schema_name, pg_size_pretty(sum(table_size)::bigint) as "disk space", ( as "percent" FROM ( SELECT pg_catalog.pg_namespace.nspname as schema_name, pg_relation_size(pg_catalog.pg_class.oid) as table_si