MySql教程

MySQL——企业SQL优化方案

本文主要是介绍MySQL——企业SQL优化方案,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
一、大表
    (1)列多:
            纵向拆分大表:
                create t1;
                insert into t1 select id, name from test;

    (2)行多:
            根据数据存放特点和逻辑进行横向拆分大表:
                a: 表分区
                b: 分表(分多个表):
                        创建和原表结构一模一样的表:
                            create table country_1_p1 like country_1;
                            insert into country_1_p1 select code, name, continent from country_1 order by code limit 100;








-------------------------------------------------------------------------------------------------------------------------------------------
1、两个横切的表:
使用 union或union2:
    country_1: ------> 100行数据
    country_1_p1: ------> 139行数据

    需要查询239行数据:
            select * from country_1 
            union 
            select * from country_1_p1;


2、两个纵切的表:
使用 join

  

这篇关于MySQL——企业SQL优化方案的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!