zoukankan      html  css  js  c++  java
  • DB2创建视图并授权给其他用户

    创建视图并授权给其他用户


    可以在操作系统界面、或者DB2交互界面下进行数据库操作

    查看数据库节点
    [db2inst1@ELONEHR-DB ~]$ db2 list db directory

    System Database Directory

    Number of entries in the directory = 1

    Database 1 entry:

    Database alias = ELONEHR
    Database name = ELONEHR
    Local database directory = /hehrdta
    Database release level = d.00
    Comment =
    Directory entry type = Indirect
    Catalog database partition number = 0
    Alternate server hostname =
    Alternate server port number =

    [db2inst1@ELONEHR-DB ~]$ db2
    (c) Copyright IBM Corporation 1993,2007
    Command Line Processor for DB2 Client 9.7.7

    You can issue database manager commands and SQL statements from the command
    prompt. For example:
    db2 => connect to sample
    db2 => bind sample.bnd

    For general help, type: ?.
    For command help, type: ? command, where command can be
    the first few keywords of a database manager command. For example:
    ? CATALOG DATABASE for help on the CATALOG DATABASE command
    ? CATALOG for help on all of the CATALOG commands.

    To exit db2 interactive mode, type QUIT at the command prompt. Outside
    interactive mode, all commands must be prefixed with 'db2'.
    To list the current command option settings, type LIST COMMAND OPTIONS.

    For more detailed help, refer to the Online Reference Manual.


    db2 => connect to ELONEHR

    Database Connection Information

    Database server = DB2/LINUXX8664 9.7.7
    SQL authorization ID = DB2INST1
    Local database alias = ELONEHR
    数据库有哪些schema
    db2 => select name from sysibm.sysschemata

    NAME
    ---------------------------------------------------------
    DB2INST1
    EHRREAD
    NULLID
    ORA
    SQLJ
    SYSCAT
    SYSFUN
    SYSIBM
    SYSIBMADM
    SYSIBMINTERNAL
    SYSIBMTS
    SYSPROC
    SYSPUBLIC
    SYSSTAT
    SYSTOOLS
    ELONEHR

    16 record(s) selected.
    创建视图
    db2 =>create view ELONEHR.V_TB_INF_EMPLOYEE_PART as select * from ELONEHR.TB_INF_EMPLOYEE_PART

    查询视图
    db2 =>select tabschema||tabname from syscat.tables where TYPE = 'V' and tabname='V_TB_INF_EMPLOYEE_PART'

    将ELONEHR的视图V_TB_INF_EMPLOYEE_PART赋权给EHRREAD
    db2 => GRANT SELECT ON ELONEHR.V_TB_INF_EMPLOYEE_PART TO USER EHRREAD
    DB20000I The SQL command completed successfully.

    查询数据库表结构
    db2 =>describe table tbname
    db2 => describe table syscat.tabauth

    查看数据库用户权限
    db2 => select TABSCHEMA,TABNAME,SELECTAUTH from syscat.tabauth where GRANTEE='EHRREAD' and TABNAME='V_TB_INF_EMPLOYEE_PART'


    特权信息存储在七个系统编目视图中:

    SYSCAT.DBAUTH 数据库特权
    SYSCAT.COLAUTH 表和视图列特权
    SYSCAT.INDEXAUTH 索引特权
    SYSCAT.PACKAGEAUTH 包特权
    SYSCAT.SCHEMAAUTH 模式特权
    SYSCAT.TABAUTH 表和视图特权
    SYSCAT.TBSPACEAUTH 表空间特权

  • 相关阅读:
    OpenGL入门学习
    linux下安装sqlite3
    SQLite 之 C#版 System.Data.SQLite 使用
    .net程序运行流程
    一种简单,轻量,灵活的C#对象转Json对象的方案
    C# 获取Windows系统:Cpu使用率,内存使用率,Mac地址,磁盘使用率
    WPF中选择文件及文件夹
    要想创业成功,千万不能在这十个方面走弯路
    [译]Quartz.Net 框架 教程(中文版)2.2.x 之第三课 更多关于Jobs和JobDetails
    [译]Quartz 框架 教程(中文版)2.2.x 之第二课 Quartz API,Jobs和Triggers简介
  • 原文地址:https://www.cnblogs.com/elontian/p/11272149.html
Copyright © 2011-2022 走看看