Current location - Loan Platform Complete Network - Big data management - How to add multiple fields to a table in mysql at one time?
How to add multiple fields to a table in mysql at one time?

1. The command to add a field is as follows: alter table tableName add newColumn varchar(8) comment 'Newly added field'

1. Add a single-line field:

ALTER TABLE role

ADD `module` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'module';

2. Add multi-line fields:

ALTER TABLE role

ADD COLUMN `module` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'module',

ADD COLUMN `type` VARCHAR(30) NOT NULL COMMENT 'item ' AFTER `default_module`;

Notes on adding fields in extended data:

1. What needs to be noted in the statement of adding fields is that comment is a comment, just like in java/ /The effect is the same.

2. You need to add single quotes after comment to enclose the comment.

3. In the script to create a new table, you can add comments by adding the comment attribute in the field definition script.

Reference materials Baidu Encyclopedia mySQL