mysql+合表‘’,Mysql中合并表

Mysql中的合并表可以把多个表合并成一个虚表,就像类似使用union视图一样;可以使用合并引擎创建合并表。合并表可以做到;

1.分离静态的和变化的数据;

2.使用相关数据的物理相邻性来优化查询,

3.设计表查询较少的数据;

4.容易维护大容量的数据的管理;

以下为案例;

mysql> show tables;

Empty set (0.00 sec)

mysql> create table t1(a int not null primary key)engine=myisam;

Query OK, 0 rows affected (0.01 sec)

mysql> create table t2(a int not null primary key)engine=myisam;

Query OK, 0 rows affected (0.01 sec)

mysql> insert into t1(a) values(1),(2);

Query OK, 2 rows affected (0.00 sec)

Records: 2 Duplicates: 0 Warnings: 0

mysql> insert into t2(a)values(1),(2);

Query OK, 2 rows affected (0.00 sec)

Records: 2 Duplicates: 0 Warnings: 0

mysql> create table mrg(a int not null primary key)

-> engine=merge union=(t1,t2)insert_method=last;

Query OK, 0 rows affected (0.00 sec)

mysql> select a from mrg;

+---+

| a |

+---+

| 1 |

| 1 |

| 2 |

| 2 |

+---+

4 rows in set (0.00 sec)

mysql>

mysql>

mysql>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值