mysql常用命令

SQL表操作与数据处理技巧

重命名 rename table oldname to newname
修改表长度: alter table poi3 modify poi_name varchar(400);
建联合索引(也可以去重复):
唯一:alter ignore table poi3 add unique index poi_name,address,phone_number);
其他:alter table xc add index ind_name(name),add index ind_status(status);
删除索引:drop index addr_index on poi3;
查看建表语句: show create table name;
给表增加字段:alter table poi3 add rpoi_id int(11) ;
删除字段:alter table r_poi drop column fir_copy;
修改表:
alter table r_poi modify smell double(5,1),modify server double(5,1),modify aura double(5,1);
 导出查询结果:
mysql -uroot -plbs26ps lbs_comment -e"select sc from r_poi_comment limit 20">1.txt


操作数值:
四舍五入:round()
舍去小数: floor()
如果小数部分有值就进一 ceil() 或者 ceiling()
排重:
insert into temp(poi_id,img) select poi_id,url from r_poi_img;
insert into temp1(id) select id from temp group by poi_id having count(distinct poi_id) =1;

 

loadfile:

mysql -h127.0.0.1 -uroot -pyicha.123 smartad -e "LOAD DATA LOCAL INFILE 'click_temp.txt' into table click_temp (ad_id)";

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值