在DB2中,显示表的定义
大家好,我正在学习DB2,想知道如何 创建表后查看表的特征 类似于MySQL中的EXPLAIN TABLE命令在DB2中,显示表的定义,db2,Db2,大家好,我正在学习DB2,想知道如何 创建表后查看表的特征 类似于MySQL中的EXPLAIN TABLE命令 谢谢。所有这些元数据都保存在SYSIBM“schema”中的DB2目录表中。DB2/z大型机产品和DB2/LUW分布式产品的情况有所不同,但随着每个版本的发布,它们越来越接近 IBM方便地将其所有手册放在publib站点上,供全世界访问。我的专业领域DB2/z拥有您想要的页面 有许多表需要您参考: SYSTABLES for table information. SYSI
谢谢。所有这些元数据都保存在SYSIBM“schema”中的DB2目录表中。DB2/z大型机产品和DB2/LUW分布式产品的情况有所不同,但随着每个版本的发布,它们越来越接近 IBM方便地将其所有手册放在publib站点上,供全世界访问。我的专业领域DB2/z拥有您想要的页面 有许多表需要您参考:
SYSTABLES for table information.
SYSINDEXES \
SYSINDEXPART + for index information.
SYSKEYS /
SYSCOLUMNS for column information.
所有信息中心的列表是,如果您感兴趣的领域是DB2/LUW版本,则应该指向该版本。描述表的语法
db2 describe table <tablename>
或
查看所有表格详细信息
select * from syscat.tables
select * from sysibm.tables
除了描述表格外,您还可以使用以下命令
DESCRIBE INDEXES FOR TABLE *tablename* SHOW DETAIL
获取有关表索引的信息
关于Db2 for Linux、UNIX和Windows上的表的最全面的详细信息可以从db2look实用程序中获得,您可以从远程客户机或作为本地用户直接在Db2服务器上运行该实用程序。该工具生成DDL和模拟表格及其统计数据所需的其他信息。DB211.5中db2look的文档如下所示
下面的db2look命令将连接到SALESDB数据库,并获取重新创建ORDERS表所需的DDL语句
db2look -d SALESDB -e -t ORDERS
描述表语法
describe table schemaName.TableName
我知道这是个老生常谈的问题,但这就行了
SELECT colname, typename, length, scale, default, nulls
FROM syscat.columns
WHERE tabname = '<table name>'
AND tabschema = '<schema name>'
ORDER BY colno
右键单击DB2ControlCenter中的表并选择GenerateDDL。。。这将为您提供所需的一切和更多信息。尝试以下方法:
DESCRIBE SELECT * FROM TABLE_name
您可以使用下面的命令查看DB的完整特性
db2look -d <DB NAme>-u walid -e -o
您可以使用下面的命令查看模式的完整特征
db2look -d <DB NAme> -u walid -z <Schema Name> -e -o
您可以使用下面的命令查看表的完整特征
db2look -d <DB NAme> -u walid -z <Schema Name> -t <Table Name>-e -o
您还可以访问以下链接了解更多详细信息。
db2look-d-e-z-t-i-w>.sql
有关更多信息,请参阅以下内容:
db2look [-h]
-d: Database Name: This must be specified
-e: Extract DDL file needed to duplicate database
-xs: Export XSR objects and generate a script containing DDL statements
-xdir: Path name: the directory in which XSR objects will be placed
-u: Creator ID: If -u and -a are both not specified then $USER will be used
-z: Schema name: If -z and -a are both specified then -z will be ignored
-t: Generate statistics for the specified tables
-tw: Generate DDLs for tables whose names match the pattern criteria (wildcard characters) of the table name
-ap: Generate AUDIT USING Statements
-wlm: Generate WLM specific DDL Statements
-mod: Generate DDL statements for Module
-cor: Generate DDL with CREATE OR REPLACE clause
-wrap: Generates obfuscated versions of DDL statements
-h: More detailed help message
-o: Redirects the output to the given file name
-a: Generate statistics for all creators
-m: Run the db2look utility in mimic mode
-c: Do not generate COMMIT statements for mimic
-r: Do not generate RUNSTATS statements for mimic
-l: Generate Database Layout: Database partition groups, Bufferpools and Tablespaces
-x: Generate Authorization statements DDL excluding the original definer of the object
-xd: Generate Authorization statements DDL including the original definer of the object
-f: Extract configuration parameters and environment variables
-td: Specifies x to be statement delimiter (default is semicolon(;))
-i: User ID to log on to the server where the database resides
-w: Password to log on to the server where the database resides
我刚刚遇到这个查询来描述winsql中的一个表
select NAME,TBNAME,COLTYPE,LENGTH,REMARKS,SCALE from sysibm.syscolumns
where tbcreator = 'Schema_name' and tbname='Table_name' ;
DB2版本11.0
Columns:
--------
SELECT NAME,COLTYPE,NULLS,LENGTH,SCALE,DEFAULT,DEFAULTVALUE FROM SYSIBM.SYSCOLUMNS where TBcreator ='ME' and TBNAME ='MY_TABLE' ORDER BY COLNO;
Indexes:
--------
SELECT P.SPACE, K.IXNAME, I.UNIQUERULE, I.CLUSTERING, K.COLNAME, K.COLNO, K.ORDERING
FROM SYSIBM.SYSINDEXES I
JOIN SYSIBM.SYSINDEXPART P
ON I.NAME = P.IXNAME
AND I.CREATOR = P.IXCREATOR
JOIN SYSIBM.SYSKEYS K
ON P.IXNAME = K.IXNAME
AND P.IXCREATOR = K.IXCREATOR
WHERE I.TBcreator ='ME' and I.TBNAME ='MY_TABLE'
ORDER BY K.IXNAME, K.COLSEQ;
嗨,拉杰什。。您知道有哪种查询会单独为表/索引提供-ddl语句吗?蒂希·托德。。您知道有哪种查询会单独为表/索引提供-ddl语句吗?这适用于哪些版本的DB2?我正在使用7.2,但它似乎不起作用。显然,对于较旧的版本,您需要使用sysibm而不是syscat。您好,Pax,您能在查询中列出上面的答案吗?这样对我会有很大帮助。。TIAI通过导出表并使用不同名称的create选项导入,将我的所有表复制到另一个表空间。我注意到创建了主索引。但是,由于已经存在相同的索引名,因此没有创建我的二级索引。现在,我尝试获取这些索引的ddl语句。任何人都可以给我一个db2look语句,以便只获取该数据库的索引ddl语句。要检查表上的索引,请使用下面的命令;要检查表上索引的详细信息,请使用下面的命令;要检查表上索引的详细信息,请使用下面的命令;要检查表上索引的详细信息,请使用下面的命令;要生成特定db2表的ddl,请使用许多选项。请选择搜索所需的详细信息。