Home  >  Article  >  Database  >  How to add column data in mysql

How to add column data in mysql

little bottle
little bottleOriginal
2019-05-29 16:25:349926browse

How to add column data in mysql

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn