当前位置:首页 > 开发 > 数据库 > 正文

DB2数据库操纵

发表于: 2015-04-03   作者:273514524   来源:转载   浏览:
摘要:                        DB2数据库操作 db2解锁: db2 =>; get snapshot for locks on baan db2 fo
                       DB2数据库操作
db2解锁:
db2 =>; get snapshot for locks on baan
db2 force application all
db2 terminate


db2自增长序列
create sequence a_seq       --创建序列名字为   a_seq
minvalue 1               --  最小值为      1
maxvalue 99999   ---  最大值为      99999  
start with 1            ---   开始值       1
increment by 1           ---每次增长值     1
cache 100;               ----缓存大小      100


CREATE SEQUENCE seq
AS BIGINT
START WITH 1
INCREMENT BY 1


在db2实例db2inst1上建数据库kjhsdb步骤如下:
/home/db2inst1>mkdir kjhsdb
/home/db2inst1>db2
>   create db kjhsdb on /home/db2inst1/kjhsdb using codeset UTF-8 territory US

db2 CREATE DATABASE kjhsdb AUTOMATIC STORAGE YES  ON '/home/db2inst1/' USING CODESET GBK TERRITORY CN COLLATE USING SYSTEM
db2 CREATE DATABASE report AUTOMATIC STORAGE YES  ON '/home/db2inst1/' USING CODESET GBK TERRITORY CN COLLATE USING SYSTEM
db2 CREATE DATABASE iteller AUTOMATIC STORAGE YES ON'/home/db2inst1/' USING CODESET GBK TERRITORY CN COLLATE USING SYSTEM


/home/db2inst1>chown -R db2inst1:db2grp1 kjhsdb
DB2
connect to kjhsdb

删除数据库
db2》
force application all
drop db kjhsdb


[[数据库导出:
db2look -d rbgldb -u rbgl -e -o AOE.sql
数据库导入:
db2 -tvf *.sql 导入到数据库表结构和表数据导入]]//在AIX、LINUX下操作

连接数据操作:
规则配置数据库
database name: ruledb
user: ruledb   pawd: rf123456
store: /home/qshsdb/
输入:
longin:ruledb
rule‘s password:rf123456
db2回车
db2>list db directory //查看有几个数据库实例:
db2>connect to ruledb

db2> list tables
db2> describe table gltrnlogdef
db2> list db directory//列出所有数据库
db2> list tablespaces show detail//数据库空间使用情况

db2>select * from TMVOBTRNCOD
db2>insert into gltrnlogdef (tabnam,tabidt,tabsrc,tabchnnam,jurkey) values ('pstrnseqreg',1,'001','子交易流水表','#trnknd+#thswhsdir')

db2>select * from gltrnsubdef fetch first 10 rows only
db2>select tabnam,jurkey from gltrnlogdef
db2>insert into gltrnlogdef values('tab1',2,'002','流水表','#fafaf+#fdfd')
db2>insert into gltrnlogdef(tabnam,tabsrc,jurkey)values('table1','222','#fff')

建索引
db2>CREATE INDEX GLSUBLOG_IDX3 ON GLSUBLOG (SETIDT, TRNBRC, DYNFLG);

UPDATE test SET number=number+30  WHERE id='0001';
"update login set trust=trust+'"+score+"' where name='"+name+"'";





DB2数据库操纵

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号