MAPPING TABLE

本文详细介绍了Oracle数据库中如何在分区或不分区的索引组织表上创建位图索引,以及创建位图索引时所需MAPPING TABLE的作用。MAPPING TABLE是一个HEAP表,用于存储索引组织表的逻辑ROWID。通过MAPPING TABLE,查询过程能够将位图索引中的ROWID转换为对应的物理ROWID,进而访问索引组织表或普通表。此外,文章还讨论了创建和删除位图索引及MAPPING TABLE的过程,并提供了重建和恢复MAPPING TABLE的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Oracle supports bitmap indexes on partitioned and nonpartitioned index-organized tables.A mapping table is required for creating bitmap indexes on an index-organized table.


The mapping table is a heap-organized table that stores logical rowids of the index-organized table. Specifically,each mapping table row stores one logical rowid for the corresponding index-organized table row. Thus,the mapping table provides one-to-one mapping between logical rowids of the index-organized table rows and physical rowids of the mapping table rows.


A bitmap index on an index-organized table is similar to that on a heap-organized table except that the rowids used in the bitmap index on an index-organized table are those of the mapping table as opposed to the base table. There is one mapping table for each index-organized table and it is used by all the bitmap indexes created on that index-organized table.


In both heap-organized and index-organized base tables, a bitmap index is accessed using a search key. If the key is found, the bitmap entry is converted to a physical rowid. In the case of heap-organized tables, this physical rowid is then used to access the base table. However, in the case of index-organized tables, the physical rowid is then used to access the mapping table. The access to the mapping table yields a logical rowid. This logical rowid is used to access the index-organized table.


Though a bitmap index on an index-organized table does not store logical rowids, it is still logical in nature.


大意是说:Oracle数据库支持在分区或者不分区的索引组织表(IOT)上创建位图索引。在向索引组织表创建位图索引的时候必须要有MAPPING TABLE。

MAPPING TABLE是一个HEAP表(即普通表),用来存储索引组织表的逻辑rowid。具体来说,MAPPING TABLE的每一行存储了一个逻辑rowid,用来关联索引组织表的行。因此,MAPPING TABLE的物理rowid和索引组织表的行之间产生了一对一的关联。因为索引组织表的rowid会经常变化,所以只有逻辑rowid,而不像普通表的行具有物理rowid,可以直接对应到具体的物理存放地点。在索引组织表上创建的位图索引和在普通HEAP表上创建的位图索引是类似的,只不过如果是索引组织表,那位图索引会使用MAPPING TABLE的rowid。在查询的时候,2种表都是通过key字段访问,在key字段找到之后,普通HEAP表会直接把key转换成rowid,然后通过rowid定位到具体的数据块中。但是如果是索引组织表,会通过key转换成rowid后,到MAPPING TABLE中去查找逻辑rowid,然后通过这个逻辑rowid去访问索引组织表里的数据。


SQL> create table t_testmap(eno number primary key,ename varchar2(10)) organization index;


Table created.


SQL> create bitmap index idx_map on t_testmap(ename);
create bitmap index idx_map on t_testmap(ename)
                               *
ERROR at line 1:
ORA-28669: bitmap index can not be created on an IOT with no mapping table

无法在没有mapping table的情况下给IOT创建位图索引。


SQL> create table t_testmap2(eno number primary key,ename varchar2(10)) organization index mapping table;


Table created.


SQL> create bitmap index idx_map on t_testmap2(ename);


Index created.


位图索引创建成功。


SQL> select table_name,iot_name,iot_type from user_tables;


TABLE_NAME                                   IOT_NAME                        IOT_TYPE
------------------------------            ------------------------------             ---------------------
SYS_IOT_MAP_10258                 T_TESTMAP2                     IOT_MAPPING
T_TESTMAP2                                          IOT
T_TESTMAP                                             IOT

SQL> select index_name, index_type, table_name, uniqueness from user_indexes;


INDEX_NAME                     INDEX_TYPE                  TABLE_NAME                     UNIQUENES
------------------------------    ---------------------------         ------------------------------       ------------------
IDX_MAP                                      BITMAP                      T_TESTMAP2                     NONUNIQUE
SYS_IOT_TOP_10258              IOT - TOP                   T_TESTMAP2                     UNIQUE
SYS_IOT_TOP_10256              IOT - TOP                   T_TESTMAP                       UNIQUE

这里可以看出索引组织表虽然是表,但是存储的结构是索引


SQL> drop table SYS_IOT_MAP_10258;
drop table SYS_IOT_MAP_10258
           *
ERROR at line 1:
ORA-28668: cannot reference mapping table of an index-organized table


mapping table 无法被直接删除,但是可以通过move进行删除


SQL> alter table t_testmap2 move nomapping;
alter table t_testmap2 move nomapping
            *
ERROR at line 1:
ORA-28670: mapping table cannot be dropped due to an existing bitmap index

在创建了bitmap index的时候,mapping table也无法被删除。


SQL> drop index idx_map;


Index dropped.


SQL> alter table t_testmap2 move nomapping;


Table altered.


SQL> select table_name,iot_name,iot_type from user_tables;


TABLE_NAME                     IOT_NAME                       IOT_TYPE
------------------------------ ------------------------------ ------------
T_TESTMAP2                                                                     IOT
T_TESTMAP                                                                       IOT


这时再查询就发现mapping table被删除了。


SQL> select object_name, original_name, type from recyclebin;


no rows selected

而且这种删除不会把mapping table放入回收站。

如果因为误操作等原因想恢复mapping table,可以使用以下命令重建。


SQL> alter table t_testmap move mapping table;


Table altered.


SQL> select table_name,iot_name,iot_type from user_tables;


TABLE_NAME                     IOT_NAME                        IOT_TYPE
------------------------------    -----------------------            --------------------------
SYS_IOT_MAP_10256     T_TESTMAP                      IOT_MAPPING
T_TESTMAP2                                                                          IOT
T_TESTMAP                                                                            IOT


此时mapping table又重新创建。


SQL> create bitmap index idx_map on t_testmap(ename);


Index created.

重新创建索引以进行下面的实验。


SQL> drop table t_testmap;


Table dropped.


SQL> select object_name, original_name, type from recyclebin;


OBJECT_NAME                                         ORIGINAL_NAME                             TYPE
------------------------------                             --------------------------------            -------------------------
BIN$tKX6TiUGBMLgQAB/AQATjQ==$0    IDX_MAP                                        INDEX
BIN$tKX6TiUHBMLgQAB/AQATjQ==$0    SYS_IOT_TOP_10256                IOT TOP INDEX
SYS_IOT_MAP_10256                                 SYS_IOT_MAP_10256                IOT MAPPING TABLE
BIN$tKX6TiUIBMLgQAB/AQATjQ==$0       T_TESTMAP                                 TABLE


如果直接删除表t_testmap,那么该索引组织表上关联的mapping table 和 bitmap index 会一起被放入回收站中。


SQL> flashback table t_testmap to before drop;


Flashback complete.


SQL> select table_name,iot_name,iot_type from user_tables;


TABLE_NAME                                    IOT_NAME                         IOT_TYPE
------------------------------         ------------------------------               ------------
SYS_IOT_MAP_10256                     T_TESTMAP                      IOT_MAPPING
T_TESTMAP                                       IOT
T_TESTMAP2                                     IOT


SQL> select index_name, index_type, table_name from user_indexes;


INDEX_NAME                                                      INDEX_TYPE                  TABLE_NAME
------------------------------ --------                     ---------------------------               ----------------------
BIN$tKX6TiUGBMLgQAB/AQATjQ==$0            BITMAP                            T_TESTMAP
BIN$tKX6TiUHBMLgQAB/AQATjQ==$0            IOT - TOP                        T_TESTMAP
SYS_IOT_TOP_10258                                         IOT - TOP                        T_TESTMAP2


如果使用闪回的话,那么表及其关联的mapping table , bitmap index 会一起恢复

<think>好的,用户让我介绍一下HID report mapping table。首先,我需要确认自己对HID的理解是否正确。HID是Human Interface Device的缩写,属于USB设备类别的一种,常见于键盘、鼠标、游戏手柄等。而report descriptor是HID设备用来描述其数据传输格式的,这样主机(比如电脑)就知道如何解析设备发来的数据。 接下来,HID report mapping table应该是指报告描述符中的映射表,用于将设备的物理输入(如按键、轴移动)映射到报告中的数据位。需要解释报告描述符的结构,包括用途和各个字段的作用,比如Usage Page、Usage、Logical Minimum/Maximum等。 可能用户是开发人员,正在开发HID设备,需要了解如何配置报告描述符,或者是在处理HID设备的数据解析问题。需要确保解释清晰,结合实际例子,比如键盘的按键如何映射到报告中的字节,或者游戏手柄的摇杆轴如何表示。 需要检查是否有专业术语需要进一步解释,比如Usage ID、Report Size等,避免用户混淆。同时,要注意结构,分点说明组成部分和功能,并举例说明,帮助用户理解抽象概念。最后确认回答是否符合之前的系统指令,使用中文,数学公式正确应用,如果有的话,但这里可能用不上公式,更多是数据结构说明。</think>HID报告映射表(HID Report Mapping Table)是**人机接口设备(HID)协议中的核心数据结构**,用于定义设备与主机之间的数据通信格式。其本质是一个二进制描述符(Report Descriptor),通过特定语法描述设备功能与数据报告的映射关系。 ### 核心组成部分 1. **Usage Page** 定义设备功能大类(如`0x01`=通用桌面控制,`0x06`=键盘/键区)。 2. **Usage ID** 指定具体功能(如`0x30`=X轴,`0xE0`=左Ctrl键)。 3. **Report Size** 单个数据字段的比特数(例如`8`位表示0-255范围)。 4. **Report Count** 相同类型字段的重复次数(如6个字节表示6个同时按下的键盘按键)。 5. **Logical Range** 逻辑值范围(如`Logical Minimum=0`, `Logical Maximum=100`表示摇杆百分比)。 ### 典型示例(键盘报告描述符片段) ```c Usage Page (0x07), // 键盘/键区 Usage Minimum (0xE0), // 左Ctrl键 Usage Maximum (0xE7), // Right GUI键(Win键) Logical Minimum (0), Logical Maximum (1), Report Size (1), // 1bit表示按键状态 Report Count (8), // 8个修饰键(Ctrl/Alt/Shift等) Input (Data,Var,Abs), // 输入报告,变量类型 Report Size (8), Report Count (6), // 6个普通按键 Input (Data,Array,Abs) // 数组形式表示按键码 ``` 该结构定义了一个包含: - 8个1-bit的修饰键(如Ctrl/Shift) - 6个8-bit的普通按键(如A/B/C键码) ### 关键特性 - **动态解析**:主机通过解析描述符动态生成驱动 - **位级压缩**:支持按位打包数据(如用1bit表示布尔值) - **多层嵌套**:通过`Collection`实现复杂设备结构描述(如物理/逻辑集合) 实际应用中,游戏手柄可能用`0x30`/`0x31`表示X/Y轴,VR控制器可能包含`0x84`=姿态四元数字段。理解该映射表是开发HID设备固件或实现跨平台HID解析的关键。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值