MySQL commonly used modification statements

 

-- add field

ALTER TABLE `table_column` ADD COLUMN `create_time` DATETIME COMMENT '创建时间' AFTER `column_01`;

-- delete field

alter table `tb_user` drop column `first_name` ;

-- modify default value

ALTER table tb_entity_base ALTER column security_level set DEFAULT 3; 

-- modify the properties of the column

ALTER TABLE tb_entity_hbase_columns MODIFY security_level TINYINT NOT NULL DEFAULT 3 COMMENT 'Security level: 1, public; 2, secret; 3, secret. Default: 3, secret';  

 

-- modify the uniqueness constraint

alter table tb_resource_base drop index `code_UNIQUE`;

alter table tb_resource_base add unique key `code_UNIQUE` (`code` ASC, `product_line_code` ASC);

You need to delete the unique constraint first and re-establish it again.

 

Reference address:  http://database.51cto.com/art/201011/234259.htm

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326872831&siteId=291194637