zoukankan      html  css  js  c++  java
  • 数据库作业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;
    
  • 相关阅读:
    DataGridView 鼠标双击获得行列索引
    浅谈MVC、MVP、MVVM架构模式的区别和联系
    Codeforces 336D Dima and Trap Graph 并查集
    Codeforces 601C Kleofáš and the n-thlon 概率dp
    Codeforces 311B Cats Transport 斜率优化dp
    Codeforces 908F New Year and Rainbow Roads
    Codeforces 12D Ball cdq分治
    Codeforces 291 E Tree-String Problem AC自动机
    Codeforces 932E Team Work 数学
    Codeforces 463E Caisa and Tree
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13285170.html
Copyright © 2011-2022 走看看