zoukankan      html  css  js  c++  java
  • db2中将表中的某一字段设置为自增长

    DB2可以使用generated always as identity 将某一个字段指定为自增长的字段:

    这表示id自动是一个自增长的字段,它从1开始增加每次增加1。也可以通过generated

    将字段的值通过其他字段的计算的来,比如;

    create table strategy
      (
      strategy_id decimal(17)
      GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1 )
      primary key not null,
      strategy_name varchar(200),
      area_code decimal(6,0)
      );
    create table user(name varchar(30),
      n1 integer,
      n2 integer ,
      id integer generated always as (n1+n2))

    还有另外一种是使用序列(SEQUENCE )

  • 相关阅读:
    毕业论文格式
    2018.12.14
    关于百度搜索引擎的优缺点
    2018.12.13
    2018.12.12
    2018.12.11
    2108.12.10
    2018.12.9
    2018.12.8
    2018.12.7
  • 原文地址:https://www.cnblogs.com/heml/p/3365767.html
Copyright © 2011-2022 走看看