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:
- PhpMyAdmin SQL Dump
- Version 3.3.8.1
- Http://www.phpmyadmin.net
- HOST: Export rdc.sae.sina.com.cn: 3307
- Generation Date:, January 1, August 19, 2011
- Server version: 5.1.47
- PHP version: 5.2.9
- Database: 'app _ tushow'
- Table Structure 'users'
The created code is as follows:
- Create table if not exists 'users '(
- 'Id' int (9) not null AUTO_INCREMENT,
- 'Name' varchar (32) not null,
- 'Full _ name' varchar (255) not null,
- 'Password' varchar (64) not null,
- 'Login _ count' int (10) unsigned not null default '0 ',
- 'Last _ login' int (10) unsigned not null default '0 ',
- 'Email 'varchar (64) default null,
- 'Admin' tinyint (1) DEFAULT '0 ',
- 'Users' tinyint (1) DEFAULT '0 ',
- 'Hash' char (32) default null,
- 'Url' varchar (255) default null,
- 'Locale' char (10) default null,
- Primary key ('id '),
- Unique key 'name' ('name '),
- Unique key 'hash' ('hash ')
- ) ENGINE = MyISAM default charset = utf8 AUTO_INCREMENT = 3;
- Store data in tables 'users'
- Insert into 'users' ('id', 'name', 'full _ name', 'Password', 'login _ count', 'last _ login', 'email ', 'admin', 'Guest ', 'hash', 'url', 'locale') VALUES
- (1, 'Guest ', 'Guest user', '', 0, 0, NULL, 0, 1, NULL ),
- (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!