人大金仓kingbaseV8常用sql

人大金仓kingbaseV8常用sql,第1张

人大金仓kingbaseV8常用sql 人大金仓kingbaseV8常用sql 一、数据库

– 展示大小写状况

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 '湿度'

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/zaji/5718586.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-18
下一篇2022-12-17

发表评论

登录后才能评论

评论列表(0条)

    保存