Oracle||PL/SQL 设置主键自动递增
来源:互联网 发布:斗鱼领鱼丸软件 编辑:程序博客网 时间:2024/04/29 22:39
Oracle没有设置主键auto increment 的功能,需要自己白那些序列和触发器实现主键自动递增。
示例:
创建表menu:
create table menu( menuId number(10) not null primary key, name varchar2(40) not null, id_parent number(10) not null, url varchar2(300) null);
创建序列menu_autoinc_seq:
create sequence menu_autoinc_seq minvalue 1 maxvalue 99999999 start with 1 increment by 1 nocycle nocache order;
创建触发器menu_autoinc_tg:
create or replace trigger menu_autoinc_tg before insert on menu for each row begin select menu_autoinc_seq.nextval into :new.menuId from dual; end menu_autoinc_tg;
其中end语句可以写成end;
在Command window进行创建数据库对象的时候,如果使用到了多行语句,可在结束后另起一行输入/
测试:
insert into menu values('','个人事务',0,'indi.php'); insert into menu values('','公共事务',0,'public.php');
- Oracle||PL/SQL 设置主键自动递增
- PL/SQL如何设置主键自动递增
- ORACLE设置递增主键
- 在PL/SQL Developer里设置Oracle数据库的字段自动递增功能
- 在PL/SQL Developer里设置Oracle数据库的字段自动递增功能
- oracle 怎样设置自动递增的的字段,也就是设置自动递增的ID 主键
- oracle主键自动递增设计
- pl/sql developer里主键自动增长的设置
- oracle sql自动递增
- oracle设置主键自动增长
- oracle设置主键自动增长
- oracle设置主键自动增长
- oracle 设置主键自动增长
- Oracle 主键自动增长设置
- 在oracle中建立自动递增的主键列
- 在oracle中建立自动递增的主键列
- oracle设置主键自动递增(建表_建序列_建触发器_测试),取序列值
- Oracle中主键递增
- ExtJS4.1+MVC3+Spring.NET1.3+EF5 整合三:EF构建持久层
- 基于ARM的模拟器
- 黑马程序员_IO流输入输出-缓冲区
- system与exec区别
- C++编码规范与指导
- Oracle||PL/SQL 设置主键自动递增
- 黑马程序员 类加载器 代理类
- enum枚举的研究
- hdu4512
- spoj 1811 LCS (后缀自动机 SAM)
- ARM模拟器——SkyEye的使用
- UML类图符号 各种关系说明以及举例
- 黑马程序员_IO流输入输出-装饰设计模式
- 分析ORA-12899, 迁移数据时遇到的多字节问题