mysql - PRIMARY KEY for MERGE engine don't working? -
my code :
mysql> create table super (id int primary key not null auto_increment); mysql> create table super2 (id int primary key not null auto_increment); mysql> insert super values(1),(2); mysql> insert super2 values(1),(3); mysql> alter table super engine='myisam'; mysql> alter table super2 engine='myisam'
then created merge engine table :
mysql> create table super_merge (id int primary key not null auto_increment) e ine='merge' union=(super,super2); query ok, 0 rows affected (0.00 sec) mysql> select * super_merge; +----+ | id | +----+ | 1 | | 1 | | 2 | | 3 | +----+
will not rule of uniqueness?maybe normal .
why, then, create structure of table fields if not work?
when truncate tables super,super2 table super_merge empty too!
truncate table super2; mysql> select * super_merge; empty set (0.00 sec) mysql> insert super values(1),(2); mysql> insert super2 values(1),(3); mysql> select * super_merge; +----+ | id | +----+ | 1 | | 1 | | 2 | | 3 |
this explicitly mentioned in documentation of merge engine:
note column
a
indexedprimary key
in underlying myisam tables, not in merge table. there indexed notprimary key
because merge table cannot enforce uniqueness on set of underlying tables. (similarly, columnunique
index in underlying tables should indexed in merge table notunique
index.)
a merge table unioned view on both tables, naturally removing items underlying table(s) remove items merge table (as never in merge table begin with, in underlying tables).
Comments
Post a Comment