Influence of MySQL primary key on the auto_increment Field

Source: Internet
Author: User

Let's look at the example below:

Create Table tbl_xxx (
'F _ id' int (10) Not null auto_increment comment 'id ',
'F _ province 'int (10) Not null default '0' comment' province ',
'F _ node' varchar (60) not null default ''comment 'I business node ',
'F _ Day' date not null default '2017-01-01 'comment' date ',
'F _ timesect 'int (6) Not null default '0' comment' time period (1-24 )',
'F _ failnum' int (10) Not null default '0' comment' failure count ',
'F _ sucessnum' int (10) Not null default '0' comment' successful times ',
'F _ avspeed' int (12) not null default '0' comment 'average access speed ',
Primary Key ('f _ Day', 'f _ id '),
Key 'f _ province '('f _ province', 'f _ node', 'f _ timesect ')
)

 

The primary key of the script above specifies two fields f_day and f_id, and f_id sets the auto_increment attribute. In this case, the f_id of the entire table is counted from 1 according to the different values of f_day. For example, if f_day is '2017-08-11 ', f_id is counted from 1. If '2017-08-12', f_id is also counted from 1.

The f_id of all auto_increment data increases sequentially.

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.