41.列出所有表
db2 list tables
42.插入數據:
db2 insert into tb1 values(1,’sam’);
db2 insert into tb2 values(2,’smitty’);
www.2cto.com
42. 創建 SAMPLE 數據庫
db2sampl
db2sampl F:(指定安裝盤)
43. 使用操作系統命令
! dir
44. 轉換數據類型 (cast)
SELECT EMPNO, CAST(RESUME AS VARCHAR(370))
FROM EMP_RESUME
WHERE RESUME_FORMAT = 'ascii'
45. UDF
要運行 DB2 Java 存儲過程或 UDF,還需要更新服務器上的 DB2 數據庫管理程序配置,以包括在該機器上安裝 JDK 的路徑
db2 update dbm cfg using JDK11_PATH d:sqllibjavajdk
TERMINATE
update dbm cfg using SPM_NAME sample
www.2cto.com
46. 檢查 DB2 數據庫管理程序配置
db2 get dbm cfg
47. 檢索具有特權的所有授權名
SELECT DISTINCT GRANTEE, GRANTEETYPE, 'DATABASE' FROM SYSCAT.DBAUTH
UNION
SELECT DISTINCT GRANTEE, GRANTEETYPE, 'TABLE ' FROM SYSCAT.TABAUTH
UNION
SELECT DISTINCT GRANTEE, GRANTEETYPE, 'PACKAGE ' FROM SYSCAT.PACKAGEAUTH
UNION
SELECT DISTINCT GRANTEE, GRANTEETYPE, 'INDEX ' FROM SYSCAT.INDEXAUTH
UNION
SELECT DISTINCT GRANTEE, GRANTEETYPE, 'COLUMN ' FROM SYSCAT.COLAUTH
UNION
SELECT DISTINCT GRANTEE, GRANTEETYPE, 'SCHEMA ' FROM SYSCAT.SCHEMAAUTH
UNION
SELECT DISTINCT GRANTEE, GRANTEETYPE, 'SERVER ' FROM SYSCAT.PASSTHRUAUTH
ORDER BY GRANTEE, GRANTEETYPE, 3
create table yhdab
www.2cto.com
(id varchar(10),
password varchar(10),
ywlx varchar(10),
kh varchar(10));
create table ywlbb
(ywlbbh varchar(8),
ywmc varchar(60))
48. 修改表結構
alter table yhdab ALTER kh SET DATA TYPE varchar(13);
alter table yhdab ALTER ID SET DATA TYPE varchar(13);
alter table lst_bsi alter bsi_money set data type int;
insert into yhdab values
('20000300001','123456','user01','20000300001'),
('20000300002','123456','user02','20000300002');
49. 業務類型說明
insert into ywlbb values
www.2cto.com
('user01','業務申請'),
('user02','業務撤消'),
('user03','費用查詢'),
('user04','費用自繳'),
('user05','費用預存'),
('user06','密碼修改'),
('user07','發票打印'),
('gl01','改用戶基本信息'),
('gl02','更改支付信息'),
('gl03','日統計功能'),
('gl04','沖帳功能'),
('gl05','對帳功能'),
('gl06','計費功能'),
('gl07','綜合統計')
備份數據庫:
CONNECT TO EXOA;
QUIESCE DATABASE IMMEDIATE FORCE CONNECTIONS;
CONNECT RESET; www.2cto.com
BACKUP DATABASE EXOA TO "/home/exoa2/db2bak/" WITH 2 BUFFERS BUFFER 1024 PARALLELISM 1 WITHOUT PROMPTING;
CONNECT TO EXOA;
UNQUIESCE DATABASE;
CONNECT RESET;
作者 manULinux