MySQL Modify field length
ALTER TABLE news Modify column title varchar (130);
ALTER TABLE name modify column field name type;
For example: the title field in the news table is 100 characters in length and is changed to 130 characters
ALTER TABLE news Modify column title varchar (130);
Modify a field type
The Address Table City field in the database is varchar (30)
Modifying a type can be used (carefully modifying the type may result in an error in the original data)
Mysql> ALTER TABLE address modify column City char (30);
The length standard statement for modifying a field is:
ALTER TABLE name modify column (field 1 type, field 2 type
.........) ;
Write the fields you need to modify without writing.
If there is a table name news, field name tags, original tags for char (20), now to be changed to char (200), you can write:
ALTER TABLE ' phome_enewstags ' modify column TagName char (200);
ALTER TABLE ' phome_ecms_news ' modify column filename varchar (100);
Execute it!
You can also use the following instructions
ALTER TABLE SMS_BILLBOOK_TJ change tj_type tj_type varchar (100);
ALTER TABLE name change column names varchar (100);
MySQL alter usage
1: Delete Column
ALTER table "table name" DROP "column name"
2: Adding columns
ALTER table "table name" ADD "column name" INT not NULL COMMENT ' annotation description '
3: Modify the column's type information
ALTER table "table name" Change "column name" new column name (this can be used with the same name as the original column) "BIGINT not NULL COMMENT ' comment description '
4: Renaming a column
ALTER table "table name" Change "column Name" "New column name" BIGINT not NULL COMMENT ' comment description '
5: Renaming tables
ALTER table "table name" RENAME "Table new name"
6: Delete the primary key in the table
Alter table "table name" Drop PRIMARY key
7: Add primary key
ALTER TABLE sj_resource_charges ADD CONSTRAINT pk_sj_resource_charges PRIMARY KEY (resid,resfromid)
8: Add index
ALTER TABLE sj_resource_charges Add index index_name (NAME);
9: Add a unique restricted condition index
ALTER TABLE sj_resource_charges Add unique emp_name2 (cardnumber);
10: Delete Index
ALTER TABLE tablename DROP INDEX emp_name;