您的位置:首页 > 数据库

实用sql语句

2014-03-03 20:52 239 查看

1。 加权限:

grant alter,create,select,insert,update,delete,index on recommend.* to growth@10.1.1.1 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;

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: