Mysql automatically adds the set base value statement _ MySQL
Source: Internet
Author: User
Mysql automatically adds the statement bitsCN.com that sets the base value.
Core code:
Alter table name AUTO_INCREMENT = set value
ALTER [IGNORE] TABLE tbl_name alter_spec [, alter_spec...] in MySQL ALTER syntax
Alter_specification:
ADD [COLUMN] create_definition [FIRST | AFTER column_name]
Or add index [index_name] (index_col_name ,...)
Or add primary key (index_col_name ,...)
Or add unique [index_name] (index_col_name ,...)
Or ALTER [COLUMN] col_name {set default literal | drop default}
Or CHANGE [COLUMN] old_col_name create_definition
Or MODIFY [COLUMN] create_definition
Or DROP [COLUMN] col_name
Or DROP PRIMARY KEY
Or drop index index_name
Or RENAME [AS] new_tbl_name
Or table_options
Eg:
Mysql> alter table topics change hotico hot_count int (4 );
Mysql> alter table topics alter hot_count set default 1;
Supplement:
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 conditions
Mysql> alter table name add unique index name (field name );
Example: mysql> alter table employee add unique emp_name2 (cardnumber );
MySQL ALTER syntax usage: view the index of a table
Mysql> show index from table name;
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: MySQL alter table table_name DROP field_name; bitsCN.com
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.