Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 内存表的主键必须是散列,为什么?_Mysql_Memory Table - Fatal编程技术网

Mysql 内存表的主键必须是散列,为什么?

Mysql 内存表的主键必须是散列,为什么?,mysql,memory-table,Mysql,Memory Table,我想使用内存表作为一组队列 因此,将有一个内存表,其中包含int列a和b。 查询如下: 从表中选择b,其中a=?b描述的订单限制为1000 我试过这个: create table `test_table` ( `a` int(11) not null, `b` int(11) not null, primary key (`a`,`b`) using btree ) engine=memory 但主键仍然是散列: show index from `test_table`

我想使用内存表作为一组队列

因此,将有一个内存表,其中包含int列a和b。 查询如下: 从表中选择b,其中a=?b描述的订单限制为1000

我试过这个:

create table `test_table` (
    `a` int(11) not null,
    `b` int(11) not null,
    primary key (`a`,`b`) using btree
) engine=memory
但主键仍然是散列:

show index from `test_table`

Table       Non_unique  Key_name  Seq_in_index  Column_name  Collation  Cardinality  Sub_part  Packed  Null    Index_type  Comment
----------  ----------  --------  ------------  -----------  ---------  -----------  --------  ------  ------  ----------  -------
test_table           0  PRIMARY              1  a            (NULL)          (NULL)    (NULL)  (NULL)          HASH
test_table           0  PRIMARY              2  b            (NULL)               0    (NULL)  (NULL)          HASH
这是否意味着,我需要为此类查询创建另一个keya

为什么主键不能是BTREE索引?如果我将主键更改为普通键,有什么区别


可以使用alter query修改索引类型

ALTER TABLE test_table DROP PRIMARY KEY, ADD PRIMARY KEY USING BTREE (a,b);
或者使用下面的创建查询

创建表测试\u表a int11 not null,b int11 not null,主键使用BTREEa,b engine=memory

有关内存引擎的更多详细信息,请浏览下面的链接。