Home > Database > Mysql Tutorial > Oracle,SQL Server,MySQL的自增变量设置_MySQL

Oracle,SQL Server,MySQL的自增变量设置_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-01 14:00:54
Original
952 people have browsed it

Oracle,SQL Server,MySQL的自增变量设置:

  1、MySQL的自增变量是比较好记的,使用AUTO_INCREMENT关键字,如果知道英文的就容易记忆了,如下创建一个带有自增变理的表。

  createtabletest(idintAUTO_INCREMENT 
  primarykeynotnull,namevarchar(50));

  注释:此处的id一定要申明为主键,否则会报错。

  2、SQl Server使用identity关键字,可以很容易指定从什么数开始,增幅是多少,如下: 

  createtabletest(idintidentity(100,10) 
  primarykeynotnull,namevarchar(50));

  3、Oracle不能够在创建表的时候指定自动关键字,它需要重新创建sequence,然后以"创建键.nextval"来引用: 

  createtabletest(idintprimarykey 
  notnull,namevarchar(50)); 
  createsequencetest_id(最好是表名+序列号标记) 
  incrementby1startwith1maxvalue9999;

  引用如下:

  insertintotest(test_id.nextval,’www’);

Related labels:
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