How to add column data in mysql
For an already established table, as the requirements change, you will need to add a column to this table. Of course, you can create a new table to establish a relationship to meet your needs.
But for the problem of adding only one column, you can do the following:
ALTER ... ADD COLUMN ....
1. Add a new column to the last column of the table
ALTER TABLE `tbname` ADD COLUMN `state` TINYINT(2) NOT NULL DEFAULT '0' COMMENT '0为添加1为编辑'
2. Add a new column at the specified position
ALTER TABLE `tbname` ADD COLUMN `state` TINYINT(2) NOT NULL DEFAULT '0' COMMENT '0为添加1为编辑' AFTER `column_name`;
3. Add a new column in the first column
ALTER TABLE `tbname` ADD COLUMN `state` TINYINT(2) NOT NULL DEFAULT '0' COMMENT '0为添加1为编辑' FIRST;
The above is the detailed content of How to add column data in mysql. For more information, please follow other related articles on the PHP Chinese website!