---
title: 系统视图 information_schema.columns 的使用说明-OceanBase数据库使用指南
description: 了解OceanBase数据库在实际应用中关于系统视图 information_schema.columns 的使用说明相关的常见问题和使用技巧，帮助您快速解决系统视图 information_schema.columns 的使用说明的难题。
image: https://mdn.alipayobjects.com/huamei_22khvb/afts/img/A*OSPzQ6GUQF4AAAAAQHAAAAgAeiGDAQ/original
---
切换语言

- 中文站 - 简体中文
- International - English
- 日本站 - 日本語

划线反馈

# 系统视图 information_schema.columns 的使用说明

更新时间：2026-05-25 09:11

适用版本： V3.2.x、V4.2.x 内容类型：TechNote  

`information_schema.columns` 是 OceanBase 数据库 MySQL 租户中的一个系统表，它存储了所有数据库中所有表和视图的列信息。

通过查询这个表，用户可以获取到关于数据库表结构或视图的详细信息，如列名、数据类型等信息。

**常见使用场景如下：**

- 查询一个表或视图有哪些列。
 - 查询表列是否存在，如不存在则执行 SQL 增加表列或修改列类型。

## 详细说明

**测试环境：** OceanBase 数据库 V4.2.1 BP9 版本。

### 说明一 查询时注意指定 table_schema

需要注意，由于在不同数据库中可能存在同名的表，查询 `information_schema.columns` 时需要指定 `table_schema` (数据库名)。 另外，在 SQL 中指定 `table_schema` 时才可以使用上索引，所以当数据库较多且表较多时，推荐查询 `information_schema.columns` 时指定 `table_schema`。

使用示例。

```shell
SELECT * FROM information_schema.columns WHERE table_schema = 'test' AND table_name = 'test' AND column_name = 'id';

```

### 说明二 查询视图的列信息

OceanBase 数据库 V4.x 版本起，`information_schema.columns` 开始包含视图的列信息。

使用示例。

```shell
SELECT * FROM information_schema.columns WHERE table_schema = 'test' AND table_name = 'vw_test';

```

在 OceanBase 数据库 V3.x 及之前的版本中，可以考虑通过 `DESC vw_test;` 或 `SHOW CREATE VIEW vw_test;` 等方式获取视图的列信息。

示例如下。

- 通过 `DESC vw_test;`。

  ```shell
  obclient [test]> DESC vw_test;
  +-------+---------+------+------+---------+-------+
  | Field | Type    | Null | Key  | Default | Extra |
  +-------+---------+------+------+---------+-------+
  | id    | int(11) | YES  |      | NULL    |       |
  | name  | char(2) | YES  |      | NULL    |       |
  +-------+---------+------+------+---------+-------+
  2 rows in set (0.009 sec)

  ```
 - 通过 `SHOW CREATE VIEW vw_test;` 。

  ```shell
  obclient [test]> SHOW CREATE VIEW vw_test;
  +---------+--------------------------------------------------------------------------------------------------------------+----------------------+----------------------+
  | View    | Create View                                                                                                  | character_set_client | collation_connection |
  +---------+--------------------------------------------------------------------------------------------------------------+----------------------+----------------------+
  | vw_test | CREATE VIEW `vw_test` AS select `test`.`test`.`id` AS `id`,`test`.`test`.`name` AS `name` from `test`.`test` | utf8mb4              | utf8mb4_general_ci   |
  +---------+--------------------------------------------------------------------------------------------------------------+----------------------+----------------------+
  1 row in set (0.004 sec)

  ```

## 影响租户

影响 OceanBase 数据库中的 MySQL 租户，对于 SYS 租户和 Oracle 租户无影响。

## 适用版本

OceanBase 数据库 V3.2.x、V4.2.x 版本。

Previous

[gv$ob_sql_audit 视图如何确认完整的事务上下文](https://www.oceanbase.com/knowledge-base/oceanbase-database-1000000003891639)

Next

[视图 CDB_OB_LS_REPLICA_TASKS 中任务状态一直是 INPROGRESS 的，不能结束，导致升级预检查时过不去的原因和解决方法](https://www.oceanbase.com/knowledge-base/oceanbase-database-1000000003876921) ![有帮助](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) 咨询热线
