mysql操作笔记
一.在表中加入一列:
1.1 常规:
alter table 表名 add column 需要加入的列名;
1.2 特殊需求:
例如 在表的列名2后面加入一列列名1:
alter table 表名 add column 列名1列名 列描述 after 列名2;
alter table sales_order
add column product_type varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '业务类型' after order_pattern;
在sales表里,列名为:order_pattern 的后面插入一列:product_type
类型大小为varchar(50),编码为uft8,默认为空,字段描述为:业务类型
二.删除表中的列:
alter table sales_order
drop column product_type
删除表sales的product_type列
三.为表添加时间标识
CREATE TABLE `table2` (
`ID` bigint(20)