Skip to content

Instantly share code, notes, and snippets.

@zuoRambo
Last active May 17, 2016 03:39
Show Gist options
  • Save zuoRambo/713d8e1f32a47dae81026354f0a3df6a to your computer and use it in GitHub Desktop.
Save zuoRambo/713d8e1f32a47dae81026354f0a3df6a to your computer and use it in GitHub Desktop.
some mysql snippet
-- 快速复制一个表,添加limit 0可以只保留结构
CREATE TABLE copy_table AS SELECT * FROM original_table

-- 将sql语句的查询结果保存到文件中
pager cat > /tmp/sql_result_file 
-- 设置上述命令之后执行的sql结果将不在屏幕缓冲区显示,直接写入文件

-- explain 查询计划
-- type指标的排序
system > const > eq_ref > ref > fulltext > ref_or_null > index_merge 
       > unique_subquery > index_subquery > range > index > ALL

-- extra字段
Using filesort 和 Using temporary是比较差的
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment