MYSQL auto_increment, default keyword

Source: Internet
Author: User

1.

Auto_increment:

Only one column in the InnoDB table can be auto_increment, and this column must also be indexed.

CREATE TABLE T (X int auto_increment primary key,y int); --To

CREATE table T (x int auto_increment,y int, index ix_a (x))--the auto_increment can be indexed in the wrong way

CREATE TABLE T (X int auto_increment,y int auto_increment); --the wrong table can only have one auto_increment column

2.

Default

Its value is either constant, now (), or current_date ()

CREATE TABLE T3 (X int default 100,y datetime default Now ());

INSERT into T3 (x, Y) VALUES (default,default);

INSERT into T3 (x, Y) VALUES (null,null);

MYSQL auto_increment, default keyword

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.