【IT168 服务器学院】3 DB2表及sp管理
3.1 看存储过程文本
select text from syscat.procedures where procname=''PROC1'';
3.2 看表结构
describe table syscat.procedures
describe select * from syscat.procedures
3.3 查看各表对sp的影响(被哪些sp使用)
select PROCNAME from SYSCAT.PROCEDURES where SPECIFICNAME in(select dname from sysibm.sysdependencies where bname in ( select PKGNAME
from syscat.packagedep where bname=''TB_BRANCH''))
3.4 查看sp使用了哪些表
select bname from syscat.packagedep where btype=''T'' and pkgname in(select bname from sysibm.sysdependencies where dname in (select
specificname from syscat.procedures where procname=''PR_CLEAR_MATCH_
DIVIDE_SHA''))
3.5 查看function被哪些sp使用
select PROCNAME from SYSCAT.PROCEDURES where SPECIFICNAME in(select dname from sysibm.sysdependencies where bname in ( select PKGNAME
from syscat.packagedep where bname in (select SPECIFICNAME from
SYSCAT.functions where funcname=''GET_CURRENT_DATE'')))
使用function时要注意,如果想drop 掉该function必须要先将调用该function的其它存储过程全部drop掉。
必须先创建function,调用该function的sp才可以创建成功。
3.6 修改表结构
一次给一个表增加多个字段
db2 "alter table tb_test add column t1 char(1) add column t2 char(2) add column t3 int"