How to modify field type in MySQL? |
您所在的位置:网站首页 › sql更改字段类型怎么改 › How to modify field type in MySQL? |
In MySQL, you can modify the data type of a field in the table through the alter table statement. The following article will take you through the alter table statement and introduce how to modify the field type. I hope it will be helpful to you. In MySQL, the alter table statement is used to add, modify, or delete columns (fields) in an existing table. 1. Add a field (column) alter table 表名 add 字段名 数据类型Copy after loginExample: Add a field named The new column of "Birthday", the data type is "date" alter table Persons add Birthday dateCopy after loginDescription: The type of the new column "Birthday" is date, which can store dates 2. Modification Field name alter table 表名 rename column A to BCopy after login3. Modify field type alter table 表名 alter column 字段名 数据类型Copy after loginExample: Change the table" The data type of the "Birthday" column in Persons" is changed to "year" alter table Persons alter column Birthday yearCopy after loginExplanation: The data type of the "Birthday" column is year, which can store the year in 2-digit or 4-digit format. 4. Delete fields alter table 表名 drop column 字段名Copy after loginExample:Delete the "Birthday" column in the "Person" table alter table Persons drop column BirthdayCopy after loginRelated video tutorial recommendations: "MySQL Tutorial" The above is the entire content of this article, I hope it will be helpful to everyone's learning. For more exciting content, you can pay attention to the relevant tutorial columns of the PHP Chinese website! ! ! The above is the detailed content of How to modify field type in MySQL?. For more information, please follow other related articles on the PHP Chinese website! |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |