• 数据库作业11:SQL练习7


    把查询Student表权限授给用户U1

    grant select
    on student
    to u1;
    

    点开选择,后面打勾
    把对Student表和Course表的全部权限授予用户U2和U3

    grant all privileges
    on student
    to u2,u3;
    grant all privileges
    on course
    to u2,u3;
    

    把对表SC的查询权限授予所有用户

    grant select
    on sc
    to public;
    

    无异常

    把查询Student表和修改学生学号的权限授给用户U4

    grant select,update(sno)
    on student
    to u4;
    

    把对表SC的INSERT权限授予U5用户,并允许他再将此权限授予其他用户。

    grant insert
    on sc
    to u5
    with grant option;
    

    U5授权给U6

    grant insert
    on sc
    to u6
    with grant option;
    

    把用户U4修改学生学号的权限收回

    revoke update(sno)
    on student
    from u4;
    

    权限收回成功
    收回所有用户对表SC的查询权限

    revoke select
    on sc
    from public;
    

    把用户U5对SC表的INSERT权限收回

    revoke insert
    on sc
    from u5;
    

    这里除了点插曲,显示错误,结果发现是权限问题本身就不存在,我就又重来了一遍全过程。。。

    通过角色来实现将一组权限授予一个用户。

    create role a1;
    grant select,update,insert
    on student
    to a1;
    grant a1
    to U1,U2,U3;
    revoke a1
    from U1,U2;
    exec sp_droprolemember ‘a1’,‘U1’
    exec sp_droprolemember ‘a1’,‘U2’
    
    

    角色的权限修改。

    grant delete
    on student
    to a1;
    

    差不多的操作
    使a1减少了SELECT权限

    revoke select
    on student
    from a1;
    

    修改和授权总感觉差不多

    建立计算机系学生的视图,把对该视图的SELECT权限授于王平,把该视图上的所有操作权限授于张明

    create view cs_s
    as
    select *
    from student
    where sdept=‘cs’;
    
    grant select
    on cs_s
    to 王平;
    
    grant all
    on cs_s
    to 张明;
    

    对修改SC表结构或修改SC表数据的操作进行审计

    audit alter,update
    on sc;
    

    审计时有部分语法错误

    取消对SC表的一切审计

    onaudit alter,update
    on sc;
    
  • 相关阅读:
    将Web项目War包部署到Tomcat服务器基本步骤(完整版)
    性能实战分析-环境搭建(一)
    SQL Server Profiler追踪数据库死锁
    性能测试的各种监控工具大全
    python学习
    Linux常见面试题一
    Linux下用于查看系统当前登录用户信息的4种方法
    HDU 1394 Minimum Inversion Number(线段树求逆序对)
    SGU 180 Inversions(离散化 + 线段树求逆序对)
    Codeforces Round #FF (Div. 2) C. DZY Loves Sequences
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13285170.html
Copyright © 2020-2023  润新知