Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7484716
  • 博文数量: 368
  • 博客积分: 9600
  • 博客等级: 上校
  • 技术积分: 18875
  • 用 户 组: 普通用户
  • 注册时间: 2009-01-01 00:00
文章分类

全部博文(368)

文章存档

2017年(9)

2016年(19)

2015年(3)

2014年(6)

2013年(8)

2012年(78)

2011年(66)

2010年(135)

2009年(44)

分类: Mysql/postgreSQL

2013-02-04 18:48:31

      今天把数据库从5.0的一个mysql版本迁移到mysql 5.1的过程中遇到一个问题,发现一个MERGE表一直出现Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist报错,但是在5.0上一直是OK的,于是进行了一些实践后发现是由于MERGE的表索引和其他子表不一致导致。
添加索引之后正常了。而为什么5.0是正常的呢,我猜测是由于5.0的版本对MERGE表没有那么严格的要求。
因此当遇到Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist报错的时候需要从如下几个方面入手:
1、查看是不是有一些表不是MYISAM引擎的表,因为MERGE引擎只适用于MYISAM表
2、查看是不是在union的表中含有不存在的表。
3、查看是不是MERGE的时候引用了不在同一个库的表,并且该表没有指定数据库名字。
4、比较各个表的结构(索引、引擎、列、字符集等)是否一致。

子表代码为:

CREATE TABLE `test0` (
  `uin` int(10) unsigned NOT NULL,
  `data` text NOT NULL,
  `modtime` int(10) unsigned NOT NULL,
  PRIMARY KEY (`uin`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE `test1` (
  `uin` int(10) unsigned NOT NULL,
  `data` text NOT NULL,
  `modtime` int(10) unsigned NOT NULL,
  PRIMARY KEY (`uin`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE `test2` (
  `uin` int(10) unsigned NOT NULL,
  `data` text NOT NULL,
  `modtime` int(10) unsigned NOT NULL,
  PRIMARY KEY (`uin`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE `test3` (
  `uin` int(10) unsigned NOT NULL,
  `data` text NOT NULL,
  `modtime` int(10) unsigned NOT NULL,
  PRIMARY KEY (`uin`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE `test4` (
  `uin` int(10) unsigned NOT NULL,
  `data` text NOT NULL,
  `modtime` int(10) unsigned NOT NULL,
  PRIMARY KEY (`uin`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE `test5` (
  `uin` int(10) unsigned NOT NULL,
  `data` text NOT NULL,
  `modtime` int(10) unsigned NOT NULL,
  PRIMARY KEY (`uin`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE `test6` (
  `uin` int(10) unsigned NOT NULL,
  `data` text NOT NULL,
  `modtime` int(10) unsigned NOT NULL,
  PRIMARY KEY (`uin`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE `test7` (
  `uin` int(10) unsigned NOT NULL,
  `data` text NOT NULL,
  `modtime` int(10) unsigned NOT NULL,
  PRIMARY KEY (`uin`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE `test8` (
  `uin` int(10) unsigned NOT NULL,
  `data` text NOT NULL,
  `modtime` int(10) unsigned NOT NULL,
  PRIMARY KEY (`uin`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE `test9` (
  `uin` int(10) unsigned NOT NULL,
  `data` text NOT NULL,
  `modtime` int(10) unsigned NOT NULL,
  PRIMARY KEY (`uin`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

 

 

MERGE表代码为:

 

CREATE TABLE `test` (
  `uin` int(10) unsigned NOT NULL,
  `data` text NOT NULL,
  `modtime` int(10) unsigned NOT NULL,
  PRIMARY KEY  (`uin`),
  KEY `modtime` (`modtime`)
) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`test0`,`test1`,`test2`,`test3`,`test4`,`test5`,`test6`,`test7`,`test8`,`test9`);

 

阅读(7540) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~