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

查看:32
本文介绍了使用 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 版本号如下.

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

运行此查询:

db2 LIST TABLES

这相当于 MySQL 中的 SHOW TABLES.

This is the equivalent of SHOW TABLES in MySQL.

在运行 list tables 命令之前,您可能需要对正确的架构执行set schema myschema".默认情况下,登录时您的架构与您的用户名相同 - 通常不包含任何表.您可以使用values current schema"来检查您当前设置的架构.

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天全站免登陆