проблем с индекси при mysql
1 отговора
244 прегледа
проблем с индекси при mysql
Наложи ми се да dump-на и да преместа база на клиент от един сървър на друг и се получи странна грешка. Mysqldump беше dump-нал следното нещо:
CREATE TABLE `store_category` (
`category` text NOT NULL,
`cat_id` int(16) NOT NULL auto_increment,
`cat_father_id` int(16) NOT NULL default '0',
`cat_image` varchar(250) NOT NULL default '',
`per_ship` decimal(20,2) NOT NULL default '0.00',
`item_ship` decimal(20,2) NOT NULL default '0.00',
`item_int_ship` decimal(20,2) NOT NULL default '0.00',
`per_int_ship` decimal(20,2) NOT NULL default '0.00',
PRIMARY KEY (`cat_id`,`cat_id`)
) TYPE=MyISAM;
И заради PRIMARY KEY (`cat_id`,`cat_id`) заявката не можа да мине на другия сървър. След изследване на таблицата стигнах до:
mysql> show index from store_category;
+----------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+----------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| store_category | 0 | PRIMARY | 1 | cat_id | A | NULL | NULL | NULL | | BTREE | |
| store_category | 0 | PRIMARY | 2 | cat_id | A | 0 | NULL | NULL | | BTREE | |
+----------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
и после:
mysql> drop index cat_id on store_category;
ERROR 1091 (42000): Can't DROP 'cat_id'; check that column/key exists
От какво се получава това? Не, че е болка за умиране, но ми е интересно къде е проблема. Версията е 4.1.11 и за момента няма възможност за upgrade.
CREATE TABLE `store_category` (
`category` text NOT NULL,
`cat_id` int(16) NOT NULL auto_increment,
`cat_father_id` int(16) NOT NULL default '0',
`cat_image` varchar(250) NOT NULL default '',
`per_ship` decimal(20,2) NOT NULL default '0.00',
`item_ship` decimal(20,2) NOT NULL default '0.00',
`item_int_ship` decimal(20,2) NOT NULL default '0.00',
`per_int_ship` decimal(20,2) NOT NULL default '0.00',
PRIMARY KEY (`cat_id`,`cat_id`)
) TYPE=MyISAM;
И заради PRIMARY KEY (`cat_id`,`cat_id`) заявката не можа да мине на другия сървър. След изследване на таблицата стигнах до:
mysql> show index from store_category;
+----------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+----------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| store_category | 0 | PRIMARY | 1 | cat_id | A | NULL | NULL | NULL | | BTREE | |
| store_category | 0 | PRIMARY | 2 | cat_id | A | 0 | NULL | NULL | | BTREE | |
+----------------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
и после:
mysql> drop index cat_id on store_category;
ERROR 1091 (42000): Can't DROP 'cat_id'; check that column/key exists
От какво се получава това? Не, че е болка за умиране, но ми е интересно къде е проблема. Версията е 4.1.11 и за момента няма възможност за upgrade.