gaussDB的schema创建查询,及其查询下面的表列,修改列类型

修改列类型与众不同

alter table adqm_safe_data_encrypt_job_instance alter COLUMN state TYPE INT4

gaussDB的schema创建查询,及其查询下面的表列,修改列类型_第1张图片

alter COLUMN state TYPE INT4

pg_catalog.pg_namespace来查看当前数据库中全部的Schema
 select oid,* from pg_catalog.pg_namespace;

创建schema

create schema gs_dqms

显示当前使用的schema
SHOW search_path;
切换当前schema
SET search_path TO gs_dqms;

查看Schema---- dgp_sd下所有表的大小:
select relname, pg_size_pretty(pg_total_relation_size(relid)) from pg_stat_user_tables where schemaname='gs_dqms' order by pg_relation_size (relid) desc;
查看所有数据库的大小
select pg_database.datname, pg_size_pretty(pg_database_size(pg_database.datname)) AS size from pg_database;
查询数据库中的所有表:(指定schema) 
select * from information_schema.tables
select * from information_schema.columns where table_schema='gs_dqms';
select * from information_schema.tables where table_schema='gs_dqms';

gaussDB的schema创建查询,及其查询下面的表列,修改列类型_第2张图片

查询数据库信息

select oid,* from pg_database where datname='adq_dgp' and datdba=16919;

查询库空间信息

select oid,* from pg_namespace where nspname='gs_dqms2023' and nspowner=16919;

relkind char r = 普通表, i = 索引, S = 序列, t = TOAST表, v = 视图, m = 物化视图, c = 组合类型, f = 外部表, p = 分区表, I = 分区索引

查询表 :

select * from pg_catalog.pg_class where relnamespace=94165 and relowner=16919 and relkind = 'r' and

gaussDB的schema创建查询,及其查询下面的表列,修改列类型_第3张图片

select* from pg_catalog.pg_attribute;

select* from pg_index;

select* from pg_constraint;

查询指定schema的存储过程 

select oid::regprocedure as proname,prosrc from pg_proc where pronamespace=(SELECT oid FROM pg_namespace where nspname ='gs_dqms') and prokind='p'

查询指定schema的函数

select oid::regprocedure as proname,prosrc from pg_proc where pronamespace=(SELECT oid FROM pg_namespace where nspname ='gs_dqms') and prokind='p' or prokind='f'

你可能感兴趣的:(数据库,sql)