zoukankan      html  css  js  c++  java
  • 视图、序列、索引的创建及用户权限


    select * from scott.emp;
    --创建视图
    create view waa as
    select * from scott.emp;
    drop view waa;
    select * from wan;
    --修改视图 or replace view
    create or replace view waa(ename) as
    select ename||'hfh' from scott.emp ;
    --视图中有 group by ,distinct ,rownum 时 不能使用delete
    create view wan as
    select sal from scott.emp group by sal ;
    delete from wan;
    --只读视图 不可以修改
    create view wa as
    select * from scott.emp where sal>3000
    with read only ;
    select * from wa;
    insert into wa(empno) values (2);
    drop view waa;
    -- 创建系列
    CREATE SEQUENCE dept_deptid_seq
    INCREMENT BY 10 --增量
    START WITH 50 --开始值
    MAXVALUE 9999 --最大值
    NOCACHE --不写入内存
    NOCYCLE; --不循环 到最大值结束

    select dept_deptid_seq.nextval from dual ; --查询下一个 先
    select dept_deptid_seq.currval from dual ; --查询当前值 后
    --修改序列 增量 最大值 循环与否
    alter sequence dept_deptid_seq
    increment by 20
    maxvalue 300
    cycle ;
    -- 删除序列
    drop sequence dept_deptid_seq;
    --创建索引
    create index suoyin
    on wan(name); --在表的某一列创建索引
    --删除索引
    drop index suoyin;

    --用户和权限
    --创建用户
    create user scott --用户名
    identified by tiger; --密码
    -- 修改密码
    alter user scott
    identified by tiger;
    --创建角色
    create role zu;
    --为角色赋予权限
    Grant create table ,create session,create view,create procedure
    To zu;
    --将角色赋予用户
    Grant zu To scott,num1,num2;











  • 相关阅读:
    创建XNA Shooter游戏——概述
    Android 界面切换与恢复原生界面
    输入和用户界面——SpaceCamera类
    ASP.NET下FCKedit配置及使用参考
    1282. Game Tree 夜
    1122. Game 夜
    1136. Parliament 夜
    hdu 3905 Sleeping 夜
    1195. Ouths and Crosses 夜
    1210. Kind Spirits 夜
  • 原文地址:https://www.cnblogs.com/xuekai/p/7241520.html
Copyright © 2011-2022 走看看