• 触发器


    http://zhidao.baidu.com/link?url=gEP3U9q13tDagS9klKCtpDgjkGWkkOMFDveW-1aNiuV3vLfSIecmMEueHVwdnv-dISb7Zx6maCjEcwGHS3jgdq

    http://www.jb51.net/article/33548.htm

    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    要先有个序列才行 
    create or replace trigger Trigger_pa_user_key

    before insert on pa_user
    for each row
    begin
     SELECT S_pa_user.nextval INTO :new.id FROM dual;
    end;
    你可以在执行插入时候  先truncate table 
     

    -- Create table
    create table USERDEMO
    (
    id NUMBER not null,
    name VARCHAR2(20)
    )
    tablespace DEMO
    pctfree 10
    initrans 1
    maxtrans 255
    storage
    (
    initial 64K
    next 1M
    minextents 1
    maxextents unlimited
    );
    -- Create/Recreate primary, unique and foreign key constraints
    alter table USERDEMO
    add constraint USERDEMO primary key (ID)
    using index
    tablespace DEMO
    pctfree 10
    initrans 2
    maxtrans 255
    storage
    (
    initial 64K
    next 1M
    minextents 1
    maxextents unlimited
    );

    ++++++++++++++++++++++++++++++++++++++++++++++++++

    -- Create sequence
    create sequence USERDEMOSEP
    minvalue 1
    maxvalue 9999999999999999999999
    start with 21
    increment by 1
    cache 20
    order;

    ++++++++++++++++++++++++++++++++++++++++++++++++++

    create or replace trigger Trigger_user_key

    before insert on userdemo
    for each row
    begin
    SELECT userdemosep.nextval INTO :new.id FROM dual;
    end;

    ++++++++++++++++++++++++++++++++++++++++++++++++++++


    insert into userdemo (name) values('jj');

    ++++++++++++++++++++++++++++++++++++++++++++++++++++

  • 相关阅读:
    swift 学习线路
    常用linux命令
    位运算常用技巧
    我的算法练习
    mac 电脑配置cordova
    swift 2中关键字和解释整理
    C# 类
    C# 循环语句 for循环(嵌套 while 穷举 迭代)
    C# 循环语句 for循环
    C# 分支语句
  • 原文地址:https://www.cnblogs.com/zshboke-2015/p/5018741.html
Copyright © 2020-2023  润新知