Greenplum+Hadoop学习笔记-14-定义数据库对象之创建与管理模式
6.3.创建与管理模式
- 概述: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 [ ... ] ] 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; 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 } 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; 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 | ******** | | | 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 ] testdw=# drop schema sc01; DROP SCHEMA |
- 系统模式
pg_catalog模式存储系统日志表.内置类型.函数和运算符。
Information_schem模式由一个标准化视图构成。
当中包括DB中对象的信息。
pg_toast模式是存储大对象(系统内部使用)
pg_bitmapindex模式存储bitmap index对象(系统内部使用)
pg_aoseg存储append-only表(系统内部使用)
gp_toolkit是管理用的模式,能够查看和检索系统日志文件和其它系统信息。
Greenplum+Hadoop学习笔记-14-定义数据库对象之创建与管理模式的更多相关文章
- Greenplum中定义数据库对象之创建与管理模式
创建与管理模式 概述:DB内组织对象的一种逻辑结构.一个DB内能够有多个模式.在未指定模式时默认放置在public中.能够通过"\dn"方式查看数据库中现有模式. testdw=# ...
- Hadoop学习笔记—14.ZooKeeper环境搭建
从字面上来看,ZooKeeper表示动物园管理员,这是一个十分奇妙的名字,我们又想起了Hadoop生态系统中,许多项目的Logo都采用了动物,比如Hadoop采用了大象的形象,所以我们可以猜测ZooK ...
- MySQL笔记(二)数据库对象的创建和管理
学校用 sqlserver ,记录数据移植到 mysql 过程中的一些问题(对应数据类型,主键外键等). 索引: 查看数据的物理路径 查看表相关的信息(SHOW CREATE TABLE.DESC) ...
- [C++学习笔记14]动态创建对象(定义静态方法实现在map查找具体类名对应的创建函数,并返回函数指针,map真是一个万能类)good
[C++学习笔记14]动态创建对象 C#/Java中的反射机制 动态获取类型信息(方法与属性) 动态创建对象 动态调用对象的方法 动态操作对象的属性 前提:需要给每个类添加元数据 动态创建对象 实 ...
- Hadoop学习笔记系列
Hadoop学习笔记系列 一.为何要学习Hadoop? 这是一个信息爆炸的时代.经过数十年的积累,很多企业都聚集了大量的数据.这些数据也是企业的核心财富之一,怎样从累积的数据里寻找价值,变废为宝炼 ...
- Hadoop学习笔记(6) ——重新认识Hadoop
Hadoop学习笔记(6) ——重新认识Hadoop 之前,我们把hadoop从下载包部署到编写了helloworld,看到了结果.现是得开始稍微更深入地了解hadoop了. Hadoop包含了两大功 ...
- Hadoop学习笔记(5) ——编写HelloWorld(2)
Hadoop学习笔记(5) ——编写HelloWorld(2) 前面我们写了一个Hadoop程序,并让它跑起来了.但想想不对啊,Hadoop不是有两块功能么,DFS和MapReduce.没错,上一节我 ...
- Hadoop学习笔记(两)设置单节点集群
本文描写叙述怎样设置一个单一节点的 Hadoop 安装.以便您能够高速运行简单的操作,使用 Hadoop MapReduce 和 Hadoop 分布式文件系统 (HDFS). 參考官方文档:Hadoo ...
- Hadoop学习笔记—5.自定义类型处理手机上网日志
转载自http://www.cnblogs.com/edisonchou/p/4288737.html Hadoop学习笔记—5.自定义类型处理手机上网日志 一.测试数据:手机上网日志 1.1 关于这 ...
随机推荐
- Android实现位图剪切
我们不能总是依赖于BitmapFactory 以下告诉大家怎么从Bitmaqp中截取某一部分创建新的Bitmap 系统会有一个默认png图片:icon.png 可是这个图片中最外层会有白色的 比較讨 ...
- win7如何清理图标缓存
rem 关闭Windows外壳程序explorer taskkill /f /im explorer.exe rem 清理系统图标缓存数据库 attrib -h -s -r "%userpr ...
- 解压tar.gz文件报错gzip: stdin: not in gzip format解决方法
解压tar.gz文件报错gzip: stdin: not in gzip format解决方法 在解压tar.gz文件的时候报错 1 2 3 4 5 [Sun@localhost Downloads] ...
- virtenv 0.8.6 发布,虚拟桌面配置工具 - 开源中国社区
virtenv 0.8.6 发布,虚拟桌面配置工具 - 开源中国社区 virtenv 0.8.6 发布,virtenv 是一个用 QT4 开发的应用,用来配置和启动基于 LXC 的虚拟桌面环境.该容器 ...
- GC日志分析
JVM的GC日志的主要參数包含例如以下几个: -XX:+PrintGC 输出GC日志 -XX:+PrintGCDetails 输出GC的具体日志 -XX:+PrintGCTimeStamps 输出GC ...
- Codeforces 549G. Happy Line 馋
非常有趣的贪婪: Let's reformulate the condition in terms of a certain height the towers, which will be on t ...
- Knockout应用开发指南 第六章:加载或保存JSON数据
原文:Knockout应用开发指南 第六章:加载或保存JSON数据 加载或保存JSON数据 Knockout可以实现很复杂的客户端交互,但是几乎所有的web应用程序都要和服务器端交换数据(至少为了本地 ...
- iOS开发人员必看的精品资料(100个)
目录下载地址:http://down.51cto.com/data/416672 附件预览如下: iOS游戏开发之Unity3D引擎系列 http://down.51cto.com/zt/399 iP ...
- Eclipse常用热键
,Ctrl+D 删除选中的几行 ,Alt+上下箭头 移动选中的代码块 ,Alt+左右箭头 回退 前进 ,Alt+Shift+上下箭头 复制选中的代码块 ,sysout+Ctrl space 生成Sys ...
- maven仓库总结,maven私服搭建
配置pom.xml依赖包时在这里找包的描述: http://search.maven.org/#browse 以java为根目录. mvn archtype:generate -DgroupId=zt ...