How does MySQL create a user table and set its ID to auto-increment column?

Source: Internet
Author: User
Tags mysql create

MySQLHow does a database create a user table and set its IDAuto-increment ColumnWhat about it? This article mainly introduces this process. First, we will introduce the testing environment, and then introduce the detailed Code created, hoping to help you.

Environment:

 
 
  1. PhpMyAdmin SQL Dump
  2. Version 3.3.8.1
  3. Http://www.phpmyadmin.net
  4. HOST: Export rdc.sae.sina.com.cn: 3307
  5. Generation Date:, January 1, August 19, 2011
  6. Server version: 5.1.47
  7. PHP version: 5.2.9
  8. Database: 'app _ tushow'
  9. Table Structure 'users'

The created code is as follows:

 
 
  1. Create table if not exists 'users '(
  2. 'Id' int (9) not null AUTO_INCREMENT,
  3. 'Name' varchar (32) not null,
  4. 'Full _ name' varchar (255) not null,
  5. 'Password' varchar (64) not null,
  6. 'Login _ count' int (10) unsigned not null default '0 ',
  7. 'Last _ login' int (10) unsigned not null default '0 ',
  8. 'Email 'varchar (64) default null,
  9. 'Admin' tinyint (1) DEFAULT '0 ',
  10. 'Users' tinyint (1) DEFAULT '0 ',
  11. 'Hash' char (32) default null,
  12. 'Url' varchar (255) default null,
  13. 'Locale' char (10) default null,
  14. Primary key ('id '),
  15. Unique key 'name' ('name '),
  16. Unique key 'hash' ('hash ')
  17. ) ENGINE = MyISAM default charset = utf8 AUTO_INCREMENT = 3;
  18. Store data in tables 'users'
  19. Insert into 'users' ('id', 'name', 'full _ name', 'Password', 'login _ count', 'last _ login', 'email ', 'admin', 'Guest ', 'hash', 'url', 'locale') VALUES
  20. (1, 'Guest ', 'Guest user', '', 0, 0, NULL, 0, 1, NULL ),
  21. (2, 'admin', 'gallery Administrator ', '', 0, 0, 'unknown @ unknown.com', 1, 0, NULL)

The above is the process of creating a user table in the MySQL database and setting its ID as an auto-incrementing column. This article will introduce it here. I hope this introduction will be helpful to you!

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.