• oracle之序列用法


    序列用于生成唯一、连续序号的对象
    序列是可以升序、降序的
    使用create sequence语句创建序列
    SQL>CREATE SEQUENCE stu_seq
        START WITH 1
        INCREMENT BY 1
        MAXVALUE 1
        MINVALUE 1
        NOCYCLE       1   #在达到最大值后停止生成下一个值
        CACHE 10      #  指定内存中预先分配的序号数

    #显示当前用户
    show user
    #查询当前用户的角色
    select * from user_role_privis;

    #查询SCOTT用户角色
    SQL> select * from dba_role_privs d where d.grantee='SCOTT';

    #查询当前用户角色对应的权限
    SQL>select * from role_sys_privs;

    #查询当前用户的序列
    select * from user_sequence;

    #通过序列的伪列来访问序列的值
    NEXTVAL  返回序列的下一个值
    CURRVAL   返回序列的当前值
    第一次使用序列对象不能返回序列当前值,只能返回序列的下一个值

    SQL>select stu_seq.nextval from dual;

    序列的用法
    create table student (
        sno number(4),
        sname varchar(2)
    );

    SQL>insert into student values(stu_seq.nextval,'xiaoming');
    SQL>insert into student values(stu_seq.nextval,'hunglong');

  • 相关阅读:
    [LeetCode]Word Break
    [LeetCode]singleNumber
    [LeetCode]Palindrome
    新浪博客无法访问
    C++基础之顺序容器
    C++基础之IO类
    [LeetCode]Restore IP Addresses
    [LeetCode]Maximal Rectangle
    [LeetCode]Reverse Linked List II
    ACM 树形数组
  • 原文地址:https://www.cnblogs.com/tanxiaojun/p/10486604.html
Copyright © 2020-2023  润新知