1.新建一个文件showtab
注意: 该文件要建在PATH值所指向的路径下,否则只能敲全路径才能执行
可以在 .bash_profile里面看到 PATH路径 (PATH=$PATH:$HOME/bin)
2.在showtab里面画点东西:
db2 connect to iccarddb user iccard using iccard
db2 "describe select * from $1"
3.为此文件附加可执行权限:
chmod 777 showtab
测试:(如果showtab没放在PATH下 则需要 showtab所在路径/showtab tableName来执行)
showtab tableName
tableName替换成要查的库表名就可以了。
测试结果:
Database Connection Information
Database server = DB2/LINUX 9.7.4
SQL authorization ID = ICCARD
Local database alias = ICCARDDB
Column Information
Number of columns: 30
SQL type Type length Column name Name length
-------------------- ----------- ------------------------------ -----------
452 CHARACTER 8 JGM 3
452 CHARACTER 40 JGMC 4
452 CHARACTER 20 JGJC 4
452 CHARACTER 8 HQORGNO 7
452 CHARACTER 8 SJJGM 5
452 CHARACTER 8 SJQSJG 6
452 CHARACTER 8 SJGLJG 6
452 CHARACTER 8 BBHZJG 6
496 INTEGER 4 WDLSH 5
452 CHARACTER 1 PZBZ 4
496 INTEGER 4 YYJD 4
496 INTEGER 4 ZT 2
452 CHARACTER 20 KZZ 3
452 CHARACTER 8 KBRQ 4
496 INTEGER 4 JGLX 4
496 INTEGER 4 JGJB 4
452 CHARACTER 60 JGFZR
======================================================
搞定!