写写gaussdb中的模式

模式

GaussDB 的模式是对数据库做一个逻辑分割。所有的数据库对象都建立在模式下面。GaussDB 200的模式和用户是弱绑定的,所谓的弱绑定是指虽然创建用户的同时会自动创建一个同名模式,但用户也可以单独创建模式,并且为用户指定其他的模式。

常用的三种模式

PUBLIC模式
缺省时每个人都在public模式上有CREATE和USAGE权限。这样就允许所有可以连接到指定数据库上的用户在这里创建对象。
Catalog模式

information_Schema模式
information_schema中几个重要试图
1.表信息: information_schema.tables ,相当于Oracle中的all_tables
2.字段信息: information_schema.columns,相当于Oracle中的all_tab_cloumns
3.权限信息:
3.1table_privileges中记录了表权限;
3.2column_privileges中记录了列上的权限;
3.3routine_privileges上记录了function/procedure的权限
3.4role_usage_grants记录了sequence/domain等类型的对象的usage权限,跟usage_privileges类似
4.视图信息:
4.1Views中记录视图基础信息;
4.2view_table_usage记录视图所依赖的表;
4.3view_routine_usage记录所依赖的function;
4.4view_column_usage记录所涉及的字段

笔记

#创建模式
create schema myschema;
create schema my_schema authorization dlpuser; #创建模式并指定所有者
#重命名
alter schema myschema rename to myschema2;
#查看当前库中模式有哪些
\dn
SELECT schema_name FROM information_schema.schemata;#包含本库中的模式和部分公共模式
#修改模式所有者
alter schema schema_name owner to new_owner;
#修改模式的永久表存储空间限制
alter schema schema_name with perm space 'space_limit';
#查看当前使用的模式
show search_path;
select current_schema;
#切换模式到test模式
set search_path to test;
set current_schema=myschema;
#查看当前库的public模式下都有哪些表
select * from information_schema.tables where table_type = 'BASE TABLE' and table_schema= 'public';
#查询当前库public模式下都有哪些表
select  * from information_schema.tables where table_type = 'BASE TABLE' and table_schema = 'public';
#查看当前库的information_schema模式下tables表的table_type列
select * from information_schema.columns where table_schema = 'information_schema' and table_name='tables' and column_name='table_type';
#查看当前库的information_schema模式下tables表的权限
select * from information_schema.table_privileges where table_schema = 'information_schema' and table_name=''tables';
#查看当前库的information_schema模式下tables表的table_type列的权限
select * from information_schema.column_privileges where table_schema = 'information_schema' and table_name='tables' and column_name='table_type';
#查看视图的基本信息
select * from information_schema.views;
#查看表与视图的关系
select view_schema,view_name,table_schema,table_name from information_schema.view_table_usage;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值