Greenplum中定义数据库对象之创建与管理模式
创建与管理模式
- 概述:DB内组织对象的一种逻辑结构。一个DB内能够有多个模式。在未指定模式时默认放置在public中。能够通过”\dn”方式查看数据库中现有模式。
|
testdw=# \dn List of schemas Name | Owner --------------------+--------- gp_toolkit | gpadmin information_schema | gpadmin pg_aoseg | gpadmin pg_bitmapindex | gpadmin pg_catalog | gpadmin pg_toast | gpadmin public | gpadmin (7 rows) |
- 创建模式:使用CREATESCHEMA命令。通过查看帮助例如以下所看到的:
|
testdw=# \h CREATE SCHEMA Command: CREATE SCHEMA Description: define a new schema Syntax: CREATE SCHEMA schemaname [ AUTHORIZATION username ] [ schema_element [ ... ] ] 将全部者设置为其它角色通过AUTHORIZTION CREATE SCHEMA AUTHORIZATION username [ schema_element [ ... ] ] |
- 訪问模式的对象:schema.table
|
testdw=# CREATE SCHEMA sc01; CREATE SCHEMA testdw=# \dn List of schemas Name | Owner --------------------+--------- gp_toolkit | gpadmin information_schema | gpadmin pg_aoseg | gpadmin pg_bitmapindex | gpadmin pg_catalog | gpadmin pg_toast | gpadmin public | gpadmin sc01 | gpadmin (8 rows) testdw=# create schema sc02 authorization mavshuang; ERROR: permission denied for database testdw (seg1 slave2:40000 pid=5424) testdw=# grant all on database testdw to mavshuang; 将testdw数据库的全部权限赋给mavshuang GRANT testdw=# create schema sc02 authorization mavshuang; CREATE SCHEMA testdw=# \dn List of schemas Name | Owner --------------------+----------- gp_toolkit | gpadmin information_schema | gpadmin pg_aoseg | gpadmin pg_bitmapindex | gpadmin pg_catalog | gpadmin pg_toast | gpadmin public | gpadmin sc01 | gpadmin sc02 | mavshuang (9 rows) |
- 模式搜索路径:若不想通过指定模式名称的方式来搜索须要的对象。能够通过设置search_path的方式来实现。第一个模式为缺省。
|
testdw=# show search_path; search_path ---------------- "$user",public (1 row) |
- 通过ALTERDATABASE改动DB的模式搜索路径
|
testdw-# \h alter database Command: ALTER DATABASE Description: change a database Syntax: ALTER DATABASE name [ [ WITH ] option [ ... ] ] where option can be: CONNECTION LIMIT connlimit ALTER DATABASE name SET parameter { TO | = } { value | DEFAULT } 通过此命令来改动DB的模式搜索路径 ALTER DATABASE name RESET parameter ALTER DATABASE name RENAME TO newname ALTER DATABASE name OWNER TO new_owner |
|
testdw=# alter database testdw set search_path to sc01,public,pg_catalog; 设置testdw数据库的搜索路径为sc01,public,pg_catalog; ALTER DATABASE testdw=# \q 改动完毕后通过\q退出testdw数据库后又一次登录 [gpadmin@master ~]$ psql -d testdw psql (8.2.15) Type "help" for help. testdw=# show search_path; search_path -------------------------- sc01, public, pg_catalog (1 row) |
- 通过ALTER ROLE改动ROLE(User)的模式搜索路径:
|
testdw-# \h alter role Command: ALTER ROLE Description: change a database role Syntax: ALTER ROLE name RENAME TO newname ALTER ROLE name SET config_parameter {TO | =} {value | DEFAULT} ALTER ROLE name RESET config_parameter ALTER ROLE name RESOURCE QUEUE {queue_name | NONE} ALTER ROLE name [ [WITH] option [ ... ] ] where option can be: SUPERUSER | NOSUPERUSER | CREATEDB | NOCREATEDB | CREATEROLE | NOCREATEROLE | CREATEEXTTABLE | NOCREATEEXTTABLE [ ( attribute='value'[, ...] ) ] where attributes and values are: type='readable'|'writable' protocol='gpfdist'|'http'|'gphdfs' | INHERIT | NOINHERIT | LOGIN | NOLOGIN | CONNECTION LIMIT connlimit | [ENCRYPTED | UNENCRYPTED] PASSWORD 'password' | VALID UNTIL 'timestamp' |
|
testdw=# select * from pg_roles; 查询pg_roles字典表 rolname | rolsuper | rolinherit | rolcreaterole | rolcreatedb | rolcatupdate | rolcanlogin | rolconnlimit | rolpassword | rolvaliduntil | rolconfig | rolresqueue | oid | rolcreaterextgpfd | rolcreaterexthttp | rolcreatewextgpfd | rolcreaterexthdfs | olcreatewexthdfs -----------+----------+------------+---------------+-------------+--------------+-------------+--------------+-------------+---------------+-----------+-------------+-------+-------------------+-------------------+-------------------+-------------------+- ----------------- mavshuang | f | t | f | f | f | t | -1 | ******** | | | 6055 | 16384 | f | f | f | f | admin | f | t | t | t | f | f | -1 | ******** | | | 6055 | 16385 | f | f | f | f | gpadmin | t | t | t | t | t | t | -1 | ******** | | | 6055 | 10 | t | t | t | t | (3 rows) testdw=# alter role mavshuang set search_path to public,sc01,pg_catalog; 改动mavshuang角色的搜索路径为public,sc01,pg_catalog; ALTER ROLE testdw=# select * from pg_roles; 再次查询显示 rolname | rolsuper | rolinherit | rolcreaterole | rolcreatedb | rolcatupdate | rolcanlogin | rolconnlimit | rolpassword | rolvaliduntil | rolconfig | rolresqueue | oid | rolcreaterextgpfd | rolcreaterexthttp | rolcreate extgpfd | rolcreaterexthdfs | rolcreatewexthdfs -----------+----------+------------+---------------+-------------+--------------+-------------+--------------+-------------+---------------+------------------------------------------+-------------+-------+-------------------+-------------------+---------- --------+-------------------+------------------- admin | f | t | t | t | f | f | -1 | ******** | | | 6055 | 16385 | f | f | f | f | f gpadmin | t | t | t | t | t | t | -1 | ******** | | | 6055 | 10 | t | t | t | t | t mavshuang | f | t | f | f | f | t | -1 | ******** | |{"search_path=public, sc01, pg_catalog"}| 6055 | 16384 | f | f | f (3 rows) |
- 查看当前的模式:通过current_schema()函数或者SHOW命令来查看:
|
testdw=# select current_schema(); 仅仅能显示一个模式 current_schema ---------------- sc01 (1 row) testdw=# show search_path; 显示当前数据库全部的模式 search_path -------------------------- sc01, public, pg_catalog (1 row) |
- 删除模式:使用DROPSCHEMA命令(空模式)
|
testdw=# \h drop schema Command: DROP SCHEMA Description: remove a schema Syntax: DROP SCHEMA [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ] 当该模式下有对象时能够使用CASCADE命令 testdw=# drop schema sc01; DROP SCHEMA |
- 系统模式
pg_catalog模式存储系统日志表.内置类型.函数和运算符。
Information_schem模式由一个标准化视图构成。当中包括DB中对象的信息。
pg_toast模式是存储大对象(系统内部使用)
pg_bitmapindex模式存储bitmap index对象(系统内部使用)
pg_aoseg存储append-only表(系统内部使用)
gp_toolkit是管理用的模式,能够查看和检索系统日志文件和其它系统信息。
Greenplum中定义数据库对象之创建与管理模式的更多相关文章
- Greenplum+Hadoop学习笔记-14-定义数据库对象之创建与管理模式
6.3.创建与管理模式 概述:DB内组织对象的一种逻辑结构.一个DB内能够有多个模式.在未指定模式时默认放置在public中.能够通过"\dn"方式查看数据库中现有模式: test ...
- MySQL笔记(二)数据库对象的创建和管理
学校用 sqlserver ,记录数据移植到 mysql 过程中的一些问题(对应数据类型,主键外键等). 索引: 查看数据的物理路径 查看表相关的信息(SHOW CREATE TABLE.DESC) ...
- Hibernate数据库对象的创建与导出
Hibernate 与数据库的关系是ORM关系,对象映射数据库. 那么如何通过对象对数据库进行各种对象的ddl与dml操作呢? 数据库对象操作的〈database-object /〉+ SchemaE ...
- MySQL中的数据库对象
1.数据库中一般包含下列对象 表.约束.索引.触发器.序列.视图: 可以使用图形用户界面或通过显式执行语句来创建这些数据库对象.用于创建这些数据库对象的语句称为“数据定义语言”(DDL),它们通常以关 ...
- VB 中定义FileSystemObject对象,要先添加对象
存取文件的方法有很多种,可以使用上述VB提供的函数,使用Windows API函数等等,但是最简单的方法是使用FileSystemObject对象. 1.使用FileSystemObject对象 F ...
- spring中容器和对象的创建流程
容器和对象的创建流程 1.先创建容器 2.加载配置文件,封装成BeanDefinition 3.调用执行BeanFactoryPostProcessor 准备工作: 准备BeanPostProcess ...
- javascript 对象的创建与继承模式
针对JS高级程序设计这本书,主要是理解概念,大部分要点源自书内.写这个主要是当个笔记加总结 存在的问题请大家多多指正! 6.1理解对象 创建对象的两个方法(暂时) //第一种,通过创建一个Object ...
- python类与对象-如何创建可管理的对象属性
如何创建可管理的对象属性 问题举例 在面向对象编程中, 我们把方法看作对象的接口, 直接访问对象的属性可能是不安全的,或设计上不够灵活. 但是使用调用方法在形式上不如访问属性简洁. circle.ge ...
- 使用 HPC Pack 为 Azure 中的 Windows HPC 工作负荷创建和管理群集的选项
利用 Microsoft HPC Pack 和 Azure 的计算与基础结构服务,创建和管理基于云的高性能计算 (HPC) 群集. HPC Pack 是在 Azure 和 Windows Server ...
随机推荐
- 图像几何变换(geometric transformation)
1. imwarp B = imwarp(A,tform) demo I = imread('cameraman.tif'); tform = affine2d([1 0 0; .5 1 0; 0 0 ...
- 配置ssh免密码登录的原理
- 爬虫--BeautifulSoup使用
解析库 解析器 使用方法 优势 劣势 Python标准库 BeautifulSoup(markup, "html.parser") Python的内置标准库.执行速度适中 .文档容 ...
- highGUI图形用户界面
#include <opencv2\core\core.hpp> #include <opencv2\highgui\highgui.hpp> using namespace ...
- JDOJ 2939: Suffix Automaton 广义后缀自动机_统计子串
建立广义后缀自动机,对每个节点都建立各自的 $Parent$ 数组. 这样方便统计,不会出现统计错误. 考虑新加入一个字符. 1 这条转移边已经存在,显然对答案没有贡献. 2 这条转移边不存在,贡献即 ...
- request.getxxxxxx()的使用方法
request.getSchema() 可以返回当前页面使用的协议,http 或是 https; request.getServerName() 可以返回当前页面所在的服务器的名字; request. ...
- 【Round #36 (Div. 2 only) B】Safe Spots
[题目链接]:https://csacademy.com/contest/round-36/task/safe-spots/ [题意] 给你n个数字构成的序列; 每个位置上的数都由0和1组成; 对于每 ...
- PatentTips - Supporting heterogeneous virtualization
BACKGROUND A virtual machine (VM) architecture logically partitions a physical machine, such that th ...
- oracle之ROWNUM的查询应用
1 在ORACLE数据库中,ROWNUM是ORACLE数据库为查询结果加入的一个伪列.起始值为1.经常使用来处理查询结果的分页. 2 因为ROWNUM的特殊性,使用时候一般是分三层: 第一层:先进行查 ...
- android ViewPager实现 跑马灯切换图片+多种切换动画
近期在弄个项目.要求有跑马灯效果的图片展示. 网上搜了一堆,都没有完美实现的算了还是自己写吧! 实现原理利用 ViewPager 控件,这个控件本身就支持滑动翻页非常好非常强大好多功能都能用上它.利用 ...