Home >Database >Mysql Tutorial >How to modify column attributes in mysql
In mysql, you can use the "ALTER TABLE table name MODIFY COLUMN column attribute after the column name is changed" statement to modify the column attributes. The ALTER command is used to modify the data table name or modify the data table field. When the parameter When set to an attribute value, the data attribute of the specified column will be modified.
The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.
How to modify column attributes in mysql
In mysql, if you want to modify column attributes, you can use the alter command.
Modify field type:
1: Delete column: ALTER TABLE [Table name] DROP [Column name]
2: Add a column: ALTER TABLE [Table name] ADD [Column name] INT NOT NULL COMMENT 'Comment description'
3: Modify the column Type information: ALTER TABLE [Table name] CHANGE [Column name] [New column name (you can use the same name as the original column here)] BIGINT NOT NULL COMMENT 'Comment'
4: Rename the column: ALTER TABLE [Table name] CHANGE [Column name] [New column name] BIGINT NOT NULL COMMENT 'Comment description'
5: Rename the table: ALTER TABLE [Table name] RENAME [Table new name]
6: Delete the primary key in the table: Alter TABLE [Table name] drop primary key
Recommended learning: mysql video tutorial
The above is the detailed content of How to modify column attributes in mysql. For more information, please follow other related articles on the PHP Chinese website!