Fre*_*tka 13
除了DESCRIBE TABLE之外,您还可以使用以下内容
DESCRIBE INDEXES FOR TABLE *tablename* SHOW DETAIL
Run Code Online (Sandbox Code Playgroud)
获取有关表索引的信息.
有关DB2 for Linux,UNIX和Windows的表的最全面的详细信息可以从db2look实用程序获得,该实用程序可以从远程客户端运行,也可以作为本地用户直接在DB2服务器上运行.该工具生成DDL和模拟表及其统计数据所需的其他信息.DB2 9.5中的db2look文档就在这里.
以下DESCRIBE TABLE命令将连接到SALESDB数据库并获取重新创建ORDERS表所需的DDL命令
db2look -d SALESDB -e -t ORDERS
Run Code Online (Sandbox Code Playgroud)
我知道这是一个老问题,但这将完成这项工作.
SELECT colname, typename, length, scale, default, nulls
FROM syscat.columns
WHERE tabname = '<table name>'
AND tabschema = '<schema name>'
ORDER BY colno
Run Code Online (Sandbox Code Playgroud)
db2look -d <db_name> -e -z <schema_name> -t <table_name> -i <user_name> -w <password>> <file_name> .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
Run Code Online (Sandbox Code Playgroud)
描述表的语法
db2 describe table <tablename>
Run Code Online (Sandbox Code Playgroud)
或所有表格详细信息
select * from syscat.tables
Run Code Online (Sandbox Code Playgroud)
或所有表格详细信息
select * from sysibm.tables
Run Code Online (Sandbox Code Playgroud)
所有这些元数据都保存在“模式”的 DB2 目录表中SYSIBM。对于 DB2/z 大型机产品和 DB2/LUW 分布式产品来说,它有所不同,但它们在每个版本中都越来越接近。
IBM 方便地将所有手册放在publib网站上,供全世界访问。我的专业领域 DB2/z在这里有您想要的页面。
您需要参考许多表格:
SYSTABLES for table information.
SYSINDEXES \
SYSINDEXPART + for index information.
SYSKEYS /
SYSCOLUMNS for column information.
Run Code Online (Sandbox Code Playgroud)
所有信息中心的列表都在这里,如果您感兴趣的话,它应该会引导您找到 DB2/LUW 版本。