zoukankan      html  css  js  c++  java
  • 不同数据库自增字段的创建实现举例

    1、MySQL: create table tableName(id int auto_increment,name varchar(20),primary key(id));
          alter table tableName auto_increment=1;


    2、SQLServer: CREATE TABLE tableName (id int identity(1,1), name varchar(10));


    3、Oracle: 创建序列,通过序列实现。
      创建序列:create sequence autoID increment by 1 start with 1 maxvalue 999999 cycle;
      插入数据:insert into tablename values(autoID.nextval,...);

      或者通过在序列的基础上创建触发器
      create or replace trigger tableName_trigger
        before insert on tableName
        for each row
        begin
          select autoID.nextval into :new.id from dual;
        end ;
      插入数据:insert into tablename (name) values('');

  • 相关阅读:
    go context
    go etcd
    go logs
    go config
    go tail
    kafka与zookeeper
    go kafka
    go mysql
    array_map array_walk
    单独配置的nginx mysql 重启
  • 原文地址:https://www.cnblogs.com/moleme/p/4936419.html
Copyright © 2011-2022 走看看