You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ALTER TABLE table_name ADD COLUMN new_column_name varchar(20) not null;
ALTER TABLE table_name ADD COLUMN new_column_name varchar(20) not null AFTER column_name;
2. 示例
增加一列:
ALTER TABLE `t_user` ADD COLUMN age varchar(20) not null;
增加指定的一列:
ALTER TABLE `t_user` ADD COLUMN age varchar(20) not null AFTER gender;
4.添加索引
1.语法
//普通索引
ALTER TABLE `table_name` ADD INDEX index_name(`column1`,`column2`,`column3`)
//唯一索引
ALTER TABLE `table_name` ADD UNIQUE INDEX index_name(`column1`,`column2`,`column3`)
2.示例
普通索引:
ALTER TABLE `operation_user_coin` ADD INDEX idx_activity_id (`activity_id`) ;
唯一索引:
ALTER TABLE `operation_user_coin` ADD UNIQUE INDEX uniq_activity_user(`coin_id`,`user_id`);
5.删除索引
1.语法
DROP INDEX index_name ON table_name;
ALTER TABLE table_name DROP index index_name;
2.示例
ALTER TABLE `wb_blog` DROP INDEX idx_user;
The text was updated successfully, but these errors were encountered:
1.建库
1.语法
2.示例
utf8mb4:
2.建表
1.语法
2.示例
utf8mb4:
3.添加字段
1. 语法
2. 示例
增加一列:
增加指定的一列:
4.添加索引
1.语法
2.示例
普通索引:
唯一索引:
5.删除索引
1.语法
2.示例
The text was updated successfully, but these errors were encountered: