Home > Database > Mysql Tutorial > Oracle自动主键功能

Oracle自动主键功能

WBOY
Release: 2016-06-07 17:19:35
Original
1009 people have browsed it

ORACLE并不存在类似Mysql和SQLSERVER的自动递增主键但是可以通过其他方式替代自动主键方法,主要有创建序列和创建触发器。在此重

Oracle并不存在类似Mysql和SQLSERVER的自动递增主键
但是可以通过其他方式替代自动主键方法,主要有创建序列和创建触发器。
在此重点介绍创建序列:
语法:
        CREATE SEQUENCE 序列名
  [INCREMENT BY n]
  [START WITH n]
  [{MAXVALUE/ MINVALUE n|NOMAXVALUE}]
  [{CYCLE|NOCYCLE}]
  [{CACHE n|NOCACHE}];
示例:
        create sequence ABC
        increment by 1
        start with 1
        maxvalue 999999999;


使用方法:当需要向一个表中插入一条数据时,,可使用查询出来的序列代替。


    查询序列的方法:
        SELECT ABC.NEXTVAL FROM SYS.DUAL;
    删除序列:
        DROP SEQUENCE ABC;


插入语句的示例

        INSERT INTO YANFAN(UUID,NAMES) VALUES(ABC.NEXTVAL,'TEST');

linux

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template