1。 加權限:
grant alter,create,select,insert,update,delete,index on recommend.* to [email protected] Identified by "growth";
flush privileges;
2. 在更新這條數據的時候更新時間:
alter table feed change update_time update_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
3. 增加唯一性限制
alter table xxx add constraint uk_1 unique (xx,xxx);
4. 查看創建語句
show create table xxx;
5. 增加聯合主鍵
alter table xxx add primary key (xx,xxx);
6. 修改列
alter table xxx change id id int(20) not null auto_increment;
7. 查看索引信息
show index from tablexxx
8. 加入字段
alter table xxx add column bbb int(11) not null default 0;
9. 插入如果重複 更新
INSERT INTO table (a,b,c) VALUES (1,2,3) ON DUPLICATE KEY UPDATE c=c+1;
10. 添加索引
alter table xxx add index `idx_bb`(`bb`);
11. 導入本地數據到msyql
LOAD DATA LOCAL INFILE '/tmp/mysql_user.csv' INTO TABLE user FIELDS TERMINATED BY ',' CHARACTER SET UTF8;