To learn about the MySQL database, MySQL auto-increment fields are one of the most basic parts. The following describes some common statements for MySQL auto-increment fields. I hope this will help you learn about MySQL auto-increment fields.
1. When creating a table, add: create table table1 (id int auto_increment primary key ,...)
2. After creating a table, add the alter table table1 add id int auto_increment primary key auto-increment field, which must be set to primary key.
Appendix: alter table mysql> alter table employee change depno int (5) not null in mysql;
Add index mysql> alter table name add index name (field name 1 [, field name 2…]);
Example: mysql> alter table employee add index emp_name (name );
Index with primary keywords mysql> alter table name add primary key (field name );
Example: mysql> alter table employee add primary key (id );
Add an index with unique restrictions mysql> alter table name add unique index name (field name );
Example: mysql> alter table employee add unique emp_name2 (cardnumber );
View the index mysql> show index from Table Name of a table; example: mysql> show index from employee;
Delete An index mysql> alter table Name drop index name; example: mysql> alter table employee drop index emp_name;
Modify TABLE: ADD a field: mysql> alter table table_name ADD field_name field_type;
View the table: mysql> SELECT * FROM table_name;
Modify the original field name and type: mysql> alter table table_name CHANGE old_field_name new_field_name field_type;
Delete field: alter table table_name DROP field_name;
The preceding describes common statements for MySQL auto-increment fields.
Mysql character encoding method
Statement for modifying fields in mysql
How to delete multiple tables in MySQL
How MySQL connects to remote SQL
MySQL cluster introduction and Configuration