– 展示大小写状况
show case_sensitive
– 修改字符编码
alter table 模式名称.表名称 CHARACTER SET utf8 COLLATE utf8_general_ci;
– 查看数据库
select * from sys_database;
– 查看表空间
select * from sys_tablespace;
– 查看语言
select * from sys_language;
– 查看角色用户
select * from sys_user;
– 查看会话进程
select * from sys_stat_activity;
– 查看当前账号会话数
select count(*), usename from sys_stat_activity group by usename;
– 查看系统所有表
SELECt * FROM sys_tables ;
–查看表字段
select * from information_schema.columns
– 查看索引
select * from sys_index ;二、查询数据库连接情况
select * from pg_stat_activity;
– 杀死空闲连接
SELECt pg_terminate_backend(pid) FROM pg_stat_activity WHERe state='idle'
– 查询最大连接数
show max_connections;
– 超级连接数
show superuser_reserved_connections;三、模式:
– 模式创建
CREATE SCHEMA 模式名称
– 模式删除
DROP SCHEMA 模式名称
– 修改模式名称
alter schema 被修改模式名称 rename to 需要重命名模式名称四、表字段
– 修改字段类型
alter table 模式名称.表名称 modify 修改字段 需要被修改字段类型;
– 删除字段
alter table 模式名称.表名称 drop 需要删除字段;
– 添加注释
comment on column 表名称.字段名称 is '注释内容';
– 创建索引
CREATE INDEX "索引名称" ON 模式名称.表名称 (字段名称);– 创建表及注释字段参考
CREATE TABLE weather ( city varchar(80),--城市 temp_lo int, -- 最低温度 temp_hi int, -- 最高温度 prcp real, -- 湿度 date date ---日期 ); comment on column weather.temp_lo is '最低温度'; comment on column weather.temp_hi is '最高温度'; comment on column weather.prcp is '湿度'



