使用LIST命令显示DB2中的所有表 [英] show all tables in DB2 using the LIST command

查看:940
本文介绍了使用LIST命令显示DB2中的所有表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这很尴尬,但是我似乎找不到找到在DB2数据库中列出表名的方法。这是我尝试的方法:

This is embarrassing, but I can't seem to find a way to list the names of the tables in our DB2 database. Here is what I tried:

root@VO11555:~# su - db2inst1
root@VO11555:~# . ~db2inst1/sqllib/db2profile
root@VO11555:~# LIST ACTIVE DATABASES

我们收到此错误: SQL1092N ROOT无权执行所请求的命令或操作。

下面是DB2版本号。

The DB2 version number follows.

root@VO11555:~# db2level
DB21085I  Instance "db2inst1" uses "64" bits and DB2 code release "SQL09071"
with level identifier "08020107".
Informational tokens are "DB2 v9.7.0.1", "s091114", "IP23034", and Fix Pack
"1".
Product is installed at "/opt/db2V9.7".


推荐答案

以获取以下内容的列表DB2中当前数据库的表->

To get a list of tables for the current database in DB2 -->

连接到数据库:

db2 connect to DATABASENAME user USER using PASSWORD

连接到DATABASENAME用户USER

Run this query:

db2 LIST TABLES

这等效于MySQL中的SHOW TABLES。

This is the equivalent of SHOW TABLES in MySQL.

在运行list table命令之前,您可能需要将 set schema myschema执行到正确的模式。默认情况下,登录时您的架构与您的用户名相同-通常不会包含任何表。您可以使用为当前架构赋值来检查当前设置为哪种架构。

You may need to execute 'set schema myschema' to the correct schema before you run the list tables command. By default upon login your schema is the same as your username - which often won't contain any tables. You can use 'values current schema' to check what schema you're currently set to.

这篇关于使用LIST命令显示DB2中的所有表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆