mysql statement:
1, modify the table name:
rename table the old table to the new table name;
2, modify field types:
alter table modify column table name field name field type (length)
3, modify the field name and type:
alter table 表名 change 现有字段名称 修改后字段名称 数据类型
4, increase the field:
alter table add the table name field name field type (length)
// Add Batch field
alter table table add (Field Name Field Type 1 (length), 2 Field Name Field Type (length), ...)
5, delete fields:
alter table table name drop column field name
// delete batch field
alter table drop column table name field name 1, drop column field names 2
6, modify the default field values:
alter table alter column table default values set default field
7, add field notes:
alter table 表名 add 字段名 字段类型(长度)default null comment '备注'
// add comments table
alter table table name comment 'Note';
Index:
1. The general index added index
the ALTER the Table 表名
the Add index index name ( 字段名
)
2. Add the primary key index Key Primary
ALTER Table 表名
the Add Primary Key ( 字段名
)
3. Add a unique index UNIQUE
the ALTER the Table 表名
the Add UNIQUE ( 字段名
)
4. Add full-text index FULLTEXT
ALTER Table 表名
the Add FULLTEXT ( 字段名
)
5. How to add multi-column index
the ALTER the Table 表名
the Add index index name ( 字段名
, 字段名
, 字段名
)