鏈接刪除 java
DELETE m FROM mtv_basecontent m INNER JOIN mtv_basecontent p ON m.parent_id=p.id WHERE p.id>1000000000 AND m.update_id=0 AND p.video_type=1 AND m.video_type=2 AND m.content_type="tv" AND p.update_id!=0
去除主鍵同時添加主鍵mysql
ALTER TABLE playstats DROP PRIMARY KEY,ADD PRIMARY KEY(id,startTime);
查看查詢效率sql
EXPLAIN PARTITIONS SELECT * FROM playstats WHERE startTime="2014-01-01 00:00:01";
查詢添加數據庫
INSERT INTO mtv_play_error(sid,source,offLine_time,result, operator_id,STATUS,title,play_url,content_type,playerr_count) SELECT b.sid,'tv189','2014-04-18 15:30:00',1,0,0,CONCAT(b.display_name,'_待處理'), m.play_url,b.content_type,0 FROM mtv_basecontent b INNER JOIN mtv_media_file m ON m.content_id=b.id WHERE m.source='tv189' AND b.id IN (1000075473,1000083541);
添加全文索引ide
ALTER IGNORE TABLE mtv_basecontent ADD FULLTEXT INDEX full_index_tagsCode (tags_code)WITH PARSER mysqlcft;
修改數據庫引擎url
Alter table mtv_account engine=innodb;
增長惟一鍵,同時去除重複數據spa
ALTER IGNORE TABLE mtv_account ADD UNIQUE INDEX account_unique_userId (user_id)
增長一列code
alter table mtv_loginLog add column user_type int(4) comment '',login_status int(4) comment '';
查看錶的狀態:排序
show table status from tvservice like 'mtv_match';
group by 組內排序索引
select * from (select * from mtv_theme_style order by create_time asc) as new group by `code`;
或者
select * from mtv_theme_style new group by code,create_time having create_time = (select min(create_time) from mtv_theme_style where code=new.code);
顯示建立表時的信息
show create table mtv_match;
鏈接更新
update A a INNER JOIN B b ON a.id=b.id set a.code = b.code WHERE a.status =1 and b.status =1