Self-variable settings for Oracle, SQL Server, and MySQL

Source: Internet
Author: User

Oracle,sql Server,mysql's self-variable setting:

1, MySQL's own variable is relatively good to remember, using the Auto_increment keyword, if you know English is easy to remember, the following to create a table with self-change.

create table test(id int AUTO_INCREMENT
primary key not null,name varchar (50));

Note: The ID here must be declared as the primary key, otherwise it will be an error.

2, SQL Server using the IDENTITY keyword, you can easily specify from what number, the increase is as follows:

create table test(id int identity(100,10)
primary key not null,name varchar (50));

3. Oracle cannot specify an automatic keyword when creating a table, it needs to recreate the sequence, and then use the "Create key. Nextval" to refer to:

create table test(id int primary key
not null,name varchar(50));
create sequence test_id(最好是表名+序列号标记)
increment by 1 start with 1 maxvalue 9999;

The reference is as follows:

insert into test(test_id.nextval,'www');

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.