Home

NUNU

02 Nov 2018

oracle 创建视图权限

    --创建用户 test_user ,并授权 连接,查询视图
    create user test_user identified by test_user;
    grant connect to test_user;
    grant create view to test_user;

    --授权视图引用的表权限给新用户
    grant select on other_user.table1 to test_user with grant option;
    grant select on other_user.table2 to test_user with grant option;
    grant select on other_user.table3 to test_user with grant option;

    -- 使用新用户 test_user 创建相关视图
    create or replace view v_1 as
    select a.*,b.*,c.* from  other_user.table1 a
    join other_user.table2 b on a.id=b.fid
    join other_user.table3 c on b.fid=c.xid

    -- 移出新用户创建视图的权限
    revoke create view from test_user;

    -- 授insert any table 权限
    grant insert any table to test_user;

    -- 授 create table 权限
    grant create table to test_user;

    -- 查询当前用户已有的权限
    select * from session_privs;


    -- 创建视图
    create view view_abc as
    select
    id
    from abc
    union all
    select
    id
    from abc_his;



    --查看用户和默认表空间的关系
    select username,default_tablespace from dba_users;
    --查看当前用户能访问的表
    select * from user_tables;
    --Oracle查询用户表
    select * from user_all_tables;

    --Oracle查询用户视图
    select * from user_views;
    --查询所有函数和储存过程:
    select * from user_source;
    --查询所有用户:
    select * from all_users;
    --select * from dba_users
    --查看当前用户连接:
    select * from v$Session;
    --查看用户角色
    SELECT * FROM USER_ROLE_PRIVS;
    --查看当前用户权限:
    select * from session_privs;
    --查看所有用户所拥有的角色
    SELECT * FROM DBA_ROLE_PRIVS;
    --查看所有角色
    select * from dba_roles;
    --查看数据库名
    SELECT NAME FROM V$DATABASE;
    --查看所有表空间使用情况
    select a.file_id "FileNo",
           a.tablespace_name "Tablespace_name",
           a.bytes "Bytes",
           a.bytes - sum(nvl(b.bytes, 0)) "Used",
           sum(nvl(b.bytes, 0)) "Free",
           sum(nvl(b.bytes, 0)) / a.bytes * 100 "%free"
      from dba_data_files a, dba_free_space b
     where a.file_id = b.file_id(+)
     group by a.tablespace_name, a.file_id, a.bytes
     order by a.tablespace_name;

业精于勤,荒于嬉; 行成于思,毁于随。
pnunu at 17:32

Flag Counter