---
title: 建表时定义 global partition index 报错-OceanBase数据库使用指南
description: 了解OceanBase数据库在实际应用中关于 建表时定义 global partition index 报错相关的常见问题和使用技巧，帮助您快速解决 建表时定义 global partition index 报错的难题。
---
切换语言

- 简体中文
- English

划线反馈

# 建表时定义 global partition index 报错

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

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

## 问题描述

建表时定义 `global partition index` 会报语法错误。

建表语句如下。

```sql
create table T1 (
a int,
b int,
c int,
CONSTRAINT pk_a PRIMARY KEY (`a`),
KEY `index_b` (`b`) GLOBAL partition by key(`b`) partitions 128);

```

返回结果如下。

```shell
ErrorCode = 1064, SQLState = 42000, Details = 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(`b`) partitions 128 at line 1

```

## 适用版本

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

## 问题原因

目前 OceanBase 数据库 V2.2.7x 及所有 V3.x 版本都不支持在建表时定义 `global partition index`。

## 解决方法

建表时不带 `global partiton index`，建表后通过以下语句创建。

```sql
create index `index_xxxx` (`xxxx`) global partition by key(`xxxx`) partitions 128;

```

Previous

[建表时不支持创建全局分区索引](https://www.oceanbase.com/knowledge-base/oceanbase-database-1000000000207733)

Next

[查询表时表不存在，错误代码 ERROR 1146](https://www.oceanbase.com/knowledge-base/oceanbase-database-1000000000217889) ![有帮助](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) 咨询热线
