---
title: 建表时不支持创建全局分区索引-OceanBase数据库使用指南
description: 了解OceanBase数据库在实际应用中关于 建表时不支持创建全局分区索引相关的常见问题和使用技巧，帮助您快速解决 建表时不支持创建全局分区索引的难题。
---
切换语言

- 简体中文
- English

划线反馈

# 建表时不支持创建全局分区索引

更新时间：2024-01-22 01:56

适用版本： V2.1.x、V2.2.x、V3.1.x、V3.2.x 内容类型：Troubleshoot  

## 问题现象

创建表时，如果有随表一起创建全局分区索引，则会报如下语法错误。

```shell
obclient > create table g1 (id int primary key, r1 int, key gdx_r1(r1) global partition by key(r1) partitions 10);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near 'partition by key(r1) partitions 10)' at line 1

```

## 问题原因

目前 OceanBase 数据库 V2.x 和 V3.x 版本都未支持建表时创建全局分区索引。

## 适用版本

OceanBase 数据库 V2.x 和 V3.x 版本。

## 解决方法

建表时不带全局分区索引，建表后再补上。

1. 创建示例表。

   ```shell
   obclient > create table g1 (id int primary key, r1 int);
   Query OK, 0 rows affected (0.105 sec)

   ```
 2. 创建全局分区索引。

   ```shell
   obclinet > create index gdx_r1 on g1(r1) global partition by key(r1) partitions 10;
   Query OK, 0 rows affected (3.452 sec)

   ```

​

Previous

[更新表错误，错误代码 5641/ORA-01843](https://www.oceanbase.com/knowledge-base/oceanbase-database-20000000197)

Next

[建表时定义 global partition index 报错](https://www.oceanbase.com/knowledge-base/oceanbase-database-1000000000426280) ![有帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*y6ocSqN8cqsAAAAAAAAAAAAAARQnAQ)![无帮助](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*BG9IQJyLHF8AAAAAAAAAAAAAARQnAQ)![反馈](https://gw.alipayobjects.com/mdn/ob_asset/afts/img/A*eTWdQKCRKHwAAAAAAAAAAAAAARQnAQ)[AI](https://www.oceanbase.com/obi) 咨询热线
