1. create database
create db testdb on /cardpro/dbdir
2. create tablespace
create tablespace tbs2 managed by database using (device '/dev/rapplv2' 4640M, device '/dev/rapplv8' 4640M )
create tablespace tbs2 managed by database using (file '/home/db2inst1/buff4000.dat' 25000)
3. connect database
connect to testdb user <userid> using <pwd>
4. create table
CREATE TABLE ACL_FUNCTION(
FUNCTION_ID CHAR(10) NOT NULL,
FUNCTION_DES CHAR(80),
MODULE_ID CHAR(10) NOT NULL,
BATRUN_STA CHAR(1),
MODIFY_TIME CHAR(30),
MODIFY_BY CHAR(10),
CONSTRAINT PKACL_FUNCTION PRIMARY KEY (FUNCTION_ID)
) IN TBS1
INDEX IN TBS6
5. create index
create index cb_finacc_acctno on cp_indacc(cb_fin_acctno)
6. select, delete, insert, update
1) select * from acl_user where user_id='test'
選擇前3條記錄: select * from acl_user fetch first 3 rows only
查詢從第m條到第n條記錄:
select * from (select ROW_NUMBER() over() as a, acl_user.* from acl_user) as acl_user where a >=5 and a<=30
2 )
insert into acl_screen_fun_map value('CCPM1900C','0',null,'CPM1900',null)
insert into acl_screen_fun_map (sceen_id, button_def) value ('CCPM1900C' , '0' )
3) delete from acl_user
delete from acl_user where user_id='test'
4)update acl_user set user_id='newtest' where user_id='test'
7. 顯示相關信息
顯示當前活動數據庫
db2 list active databases
顯示命令選項
db2 list command options
顯示系統數據庫目錄
db2 list db directory
顯示表空間
db2 list tablespaces
db2 list tablespaces show detail
顯示表空間容器
db2 list tablespace containers for tablespace-id
Example: db2 list tablespace containers for 1
顯示表
db2 list tables for schema cardpro 顯示用戶為cardpro的所有表
db2 list tables &nb