datastage与db2小结

CREATE DATABASE std104 AUTOMATIC STORAGE YES USING CODESET GBK TERRITORY CN COLLATE USING SYSTEM PAGESIZE 16384;

--无日志清空间
alter table [ORI_AAC01] activate not logged initially with empty table;


--设置codepage
db2set db2codepage=1386 -I db2inst1

--备份
db2move db100 export -sn u2,drm_u2,db2admin -u baseinfo -p baseinfo
db2move db104 import -u baseinfo -p baseinfo

--导出baseinfo.sql后,注意修改CONNECT TO STD104 USER baseinfo中的数据库名称

--注意修改结束符,否则导出函数与存储过程不能正确导入
db2look -d db100 -e -z baseinfo -td @ -i baseinfo -w baseinfo -o baseinfo.sql
--注意修改结束符
db2 -td@ -vf baseinfo.sql >db2import.log

--创建统计表信息脚本
db2 connect to db
db2 "select 'RUNSTATS ON TABLE BASEINFO.'||TABNAME||';' as aaa FROM SYSCAT.TABLES WHERE TABSCHEMA='BASEINFO'" >d:runstats2.sql

db2 "select 'RUNSTATS ON TABLE BASEINFO.'||TABLE_NAME||';' as a FROM sysibm.tables WHERE TABLE_SCHEMA='BASEINFO' AND table_type='BASE TABLE'" >D:runstats3.sql

--db2 load from db2
db2 => declare c1 cursor database stdnew user baseinfo using baseinfo for select * from paz36
DB20000I SQL 命令成功完成。
db2 => load from c1 of cursor messages d:load_paz36.msg insert into baseinfo.paz36

--监控死锁及解除死锁
db2 UPDATE MONITOR SWITCHES USING LOCK ON

db2 get snapshot for locks on db

db2 "force applications(handle) "
--force applications all

db2 UPDATE MONITOR SWITCHES USING LOCK OFF

--db2备份数据库
db2move stdnew export -u DRM_U2 -p drm_u2 -sn DRM_U2,DB2ADMIN,U2

--db2授权
CONNECT TO STANDARD;
GRANT DBADM,CREATETAB,
BINDADD,CONNECT,
CREATE_NOT_FENCED_ROUTINE,IMPLICIT_SCHEMA,
LOAD,CREATE_EXTERNAL_ROUTINE,
QUIESCE_CONNECT,SECADM
ON DATABASE TO USER DRM_U2;
CONNECT RESET;

用SQL语句实现DB2主要指标的监控

--Database manager:To capture a snapshot of database manager information:
SELECT * FROM TABLE( SNAPSHOT_DBM(-1)) as SNAPSHOT_DBM

--To capture a snapshot of database manager information specifically regarding the fast communication manager (FCM):
SELECT * FROM TABLE( SNAPSHOT_FCM(-1)) as SNAPSHOT_FCM

--To capture a snapshot of database manager information for a partition specifically regarding the fast communication manager(FCM):
SELECT * FROM TABLE( SNAPSHOT_FCMPARTITION(-1)) as SNAPSHOT_FCMPARTITION

--To capture the database manager's monitor switch settings:
SELECT * FROM TABLE( SNAPSHOT_SWITCHES(-1)) as SNAPSHOT_SWITCHES

--Database: To capture a snapshot of database information:
SELECT * FROM TABLE( SNAPSHOT_DATABASE( 'SAMPLE', -1 )) as SNAPSHOT_DATABASE

--Application:To capture a snapshot of application information:
SELECT * FROM TABLE( SNAPSHOT_APPL( 'SAMPLE', -1 )) as SNAPSHOT_APPL

--To capture a snapshot of application identification information:Chapter 3. Using the Snapshot Monitor 23
SELECT * FROM TABLE( SNAPSHOT_APPL_INFO( 'SAMPLE', -1 )) as SNAPSHOT_APPL_INFO

--To capture a snapshot of lock wait information:
SELECT * FROM TABLE( SNAPSHOT_LOCKWAIT('SAMPLE', -1 )) as SNAPSHOT_LOCKWAIT

--To capture a snapshot of statement information:
SELECT * FROM TABLE( SNAPSHOT_STATEMENT( 'SAMPLE', -1 )) as SNAPSHOT_STATEMENT

--To capture a snapshot of agent information:
SELECT * FROM TABLE( SNAPSHOT_AGENT( 'SAMPLE', -1 )) as SNAPSHOT_AGENT

--To capture a snapshot of subsection information:
SELECT * FROM TABLE( SNAPSHOT_SUBSECT( 'SAMPLE', -1 )) as SNAPSHOT_SUBSECT

--Buffer pool: To capture a snapshot of buffer pool information:
SELECT * FROM TABLE( SNAPSHOT_BP( 'SAMPLE', -1 )) as SNAPSHOT_BP

--Table space:To capture a snapshot of table space information:
SELECT * FROM TABLE( SNAPSHOT_TBS( 'SAMPLE', -1 )) as SNAPSHOT_TBS

--To capture a snapshot of table space configuration information:
SELECT * FROM TABLE( SNAPSHOT_TBS_CFG( 'SAMPLE', -1 )) as SNAPSHOT_TBS_CFG

--To capture a snapshot of table space quiescer information:
SELECT * FROM TABLE( SNAPSHOT_QUIESCER( 'SAMPLE', -1 )) as SNAPSHOT_QUIESCER

--To capture a snapshot of table space container configuration information:
SELECT * FROM TABLE( SNAPSHOT_CONTAINER( 'SAMPLE', -1 )) as SNAPSHOT_CONTAINER

--To capture a snapshot of the ranges for a table space map:
SELECT * FROM TABLE( SNAPSHOT_RANGES( 'SAMPLE', -1 )) as SNAPSHOT_RANGES

--Table: To capture a snapshot of table information:
SELECT * FROM TABLE( SNAPSHOT_TABLE( 'SAMPLE', -1 )) as SNAPSHOT_TABLE

--Lock: To capture a snapshot of lock information:
SELECT * FROM TABLE( SNAPSHOT_LOCK( 'standard', -1 )) as SNAPSHOT_LOCK

--Dynamic SQL cache: To capture a snapshot of dynamic SQL statement cache information:Snapshot monitor 24 System Monitor Guide and Reference
SELECT * FROM TABLE( SNAPSHOT_DYN_SQL( 'SAMPLE', -1 )) as SNAPSHOT_DYN_SQL



--db2中的minus(集合差集)
except

--db2中执行文件
db2 -vf filename


--db2访问oracle配置

一、安装配置Oracle客户端,用sqlplus测试能成功访问Oracle数据:

二、停止db2实例,下面以db2test实例为例:
db2stop

三、以root用户身份登录,建立包装器库与数据源客户机软件之间的链接:
su – root
###设置Oracle环境变量
export ORACLE_HOME=/oracle/app/oracle/product/9.2.0.1
### For 64位实例
/opt/IBM/db2/V8.1/bin64/djxlinkOracle
### For 32位实例
/opt/IBM/db2/V8.1/bin/djxlinkOracle
### 更新实例,保留以前的位数
/opt/IBM/db2/V8.1/instance/db2iupdt -k db2inst1
exit
### 在分区数据库环境中,若有多台物理主机上,请分别在每台机器上运行上面的djxlinkOracle及实例更新操作。

四、配置实例主目录下的sqllib/cfg/db2dj.ini,增加如下Oracle环境变量内容:
ORACLE_HOME=/oracle/app/oracle/product/9.2.0.1
ORACLE_BASE=/oracle/app/oracle
ORA_NLS33=/oracle/app/oracle/product/9.2.0.1/ocommon/nls/admin/data
TNS_ADMIN=/oracle/app/oracle/product/9.2.0.1/network/admin
NLS_LANG=american_america.zhs16cgb231280

五、修改 DBM参数FEDERATED为YES:
db2 "update dbm cfg using FEDERATED YES"

六、重启实例,并建立测试数据库:
db2start
db2 "create db testdb using codeset ISO88591 territory us"
db2 "connect to testdb"

七、注册Oracle包装器:
db2 "create wrapper net8"

八、为Oracle数据源注册服务器定义:
db2 "create server odb type oracle version 8.1.7 wrapper net8 options (node 'odb') "

九、为Oracle数据源创建用户映射:
db2 "create user mapping for db2inst1 Server odb options (remote_authid 'user', remote_password 'pwd')"

十、创建用户昵称,测试连接:
db2 "create nickname u_info for odb.sys.all_users"
db2 "select count(*) from u_info"
db2 "set passthru odb"
db2 "select count(*) from sys.all_tables"
db2 "set passthru reset"


--db2 访问sql server
0 connect to test;
1 CREATE WRAPPER MSSQLSERVER LIBRARY 'db2mssql3.dll';
2 CREATE SERVER ser_hd TYPE mssql VERSION 2000 WRAPPER MSSQLSERVER OPTIONS (NODE 'node1',DBNAME 'test');
3 CREATE USER MAPPING FOR administrator SERVER OPTIONS (REMOTE_AUTHID 'admin', REMOTE_PASSWORD '123');
administrator是db2用户,admin是mssql用户.
4 CREATE NICKNAME table01 FOR ser_hd."dbo"."table01";
5 select * from table01;
即可在db2中操作mssql中的dbo.table01表.


1、更新odbc.ini。建议:将odbc.ini文件或者它的一个拷贝放在DB2实例用户的主目录下。在我们的例子中,我们加入Microsoft SQL Server的相关条目并放在/home/db2inst1目录下,文件内容如下所示:
[ODBC Data Sources]
testsql=DataDirect 4.10 SQL SERVER
[testsql]
Driver=/opt/odbc/lib/ivmsss18.so
Description=DataDirect 4.10 SQL Server Wire Protocol
Database=Northwind
LogonID=sa
Password=sa
Address=192.168.3.3,1433
QuotedId=Yes
AnsiNPW=No
[ODBC]
Trace=1
TraceFile=odbctrace.out
TraceDll=/opt/odbc/lib/odbctrac.so
InstallDir=/opt/odbc
ConversionTableLocation=/opt/odbc/tables
UseCursorLib=0

2、设定ODBCINI环境变量,指向odbc.ini文件的绝对路径,如下所示:
export ODBCINI=/home/odbc/.odbc.ini

3、创建符号链接(请用root用户执行命令):
ln –s /opt/odbc/locale /usr/local/locale
ln –s /opt/odbc/lib/libodbcinst.so /usr/lib/libodbcinst.so
注意:如果您使用DataDirect Technoligies Connect for ODBC 4.2 驱动程序,您还必须创建下列符号链接:
ln –s /opt/odbc/lib/libivicu19.so /usr/lib/libivicu19.so
在不同的操作系统下,需要创建的符号链接不尽相同,关于其他Unix操作系统创建符号链接的信息,请参考DB2信息中心:
http://publib.boulder.ibm.com/infocenter/db2help/topic/com.ibm.db2.ii.doc/opt/tlsmss02.htm

4、使用DataDirect 公司提供的demoodbc工具测试到SQL Server的连接是否成功:
运行 /opt/odbc/odbc.sh 脚本,这个脚本设置一些ODBC驱动程序需要的环境变量。
. /opt/odbc/odbc.sh
使用demoodbc工具测试到SQL Server的连接,demoodbc位于/opt/odbc/demo目录下,请使用脚本empsqlsrv.sql在你的SQL Server端运行,在我们指定连接的数据库上(在我们的例子中是Northwind数据库,参见odbc.ini)创建EMP表, 然后运行demoodbc 来测试连接是否成功。

你需要设置一些环境变量以便DB2能够访问SQL Server数据源,如果你在安装DB2 II之前安装了Microsoft SQL Server ODBC driver,安装程序会帮助你更新db2dj.ini文件,否则你需要手工配置db2dj.ini文件。我们建议你在进行下一步之前始终检查一下你的环境变量设置。下面为在Linux环境下配置Microsoft SQL Server所需要的环境变量:
DJX_ODBC_LIBRARY_PATH
ODBCINI
DB2LIBPATH
DB2ENVLIST
关于其他操作系统的环境变量,请查看DB2信息中心:
http://publib.boulder.ibm.com/infocenter/db2help/topic/com.ibm.db2.ii.doc/opt/tlsmss12.htm

下面是手工设置这些变量的方法:
1、编辑db2dj.ini 文件,该文件位于/sqllib/cfg目录下,如果没有这个文件,请自己创建一个,在db2dj.ini文件中你必须指定全路径,否则你可能会碰到 错误。
设置如下环境变量:
DJX_ODBC_LIBRARY_PATH
该环境变量指向ODBC驱动程序的安装目录下的库文件目录(lib):
DJX_ODBC_LIBRARY_PATH=/opt/odbc/lib
ODBCINI
该变量指向ODBC配置文件,如在我们的例子中,设置如下:
ODBCINI=/home/db2inst1/odbc.ini
注意:不要将ODBCINI设置为系统环境变量。
完成编辑后我们db2dj.ini文件的内容如下:
DJX_ODBC_LIBRARY_PATH=/opt/odbc/lib
ODBCINI=/home/db2inst1/odbc.ini

2、为了访问Microsoft SQL Server数据源,你需要设置DB2LIBPATH注册表变量到ODBC驱动程序库文件所在的目录,在我们的例子中设置如下:
db2set DB2LIBPATH=/opt/odbc/lib
使用DataDirect Connect ODBC 驱动程序访问Microsoft SQL Server 数据源,设置DB2ENVLIST为LIBPATH,如:
db2set DB2ENVLIST=LIBPATH
3、为确保我们设置的环境变量生效,请重新启动DB2实例:
db2stop
db2start
八、创建联合体数据库对象访问Microsoft SQL Server数据源。接下来的任务就是创建联合体数据库对象了,你可以使用控制中心或者使用命令行创建。下面我们将简单演示一下如何使用命令行创建联合体对象访问SQL Server数据源。在创建之前需要连接到数据库(我们使用例子数据库sample):
db2 connect to sample
使用如下命令创建包装器:
db2 “create wrapper MSSQLODBC3”
使用如下命令创建联合体服务器:
db2 "create server testsql type mssqlserver version 2000 wrapper mssqlodbc3 options (dbname 'Northwind', Node 'testsql’)”
使用如下命令创建用户映射:
db2 “create user mapping for db2inst1 server "testsql" options (remote_authid 'sa', remote_password 'sa' )”
使用下列语句创建昵称(我们选择前面我们测试ODBC数据源时建立的EMP表):
db2 “create nickname testsql for testsql.dbo.emp”
测试我们的配置:
db2 connect to sample
db2 "select * from testsql"
你应该可以看到EMP表内容的输出,至此我们在Linux环境下已经成功配置了DB2 II访问Microsoft SQL Server数据库。 DB2 II除了能够采用联合体数据库访问Microsoft SQL Server 数据库以外,还支持将Microsoft SQL Server上数据源的数据复制到其他数据库平台上。您可以使用DB2复制中心来设置数据复制。关于复制的详细内容,请参见DB2信息中心。


--db2查看用户权限
GET AUTHORIZATIONS

select * from sysibm.tables where table_name like '%PRIV%';

select * from SYSIBMADM.PRIVILEGES
SELECT * FROM SYSIBM.SQLCOLPRIVILEGES
SELECT * FROM SYSIBM.SQLTABLEPRIVILEGES

select * from sysibm.tables where table_name like '%AUTHOR%';

--datastage安装
--Redhat 4 须安装以下包:
glibc-2.3.4-2.9
xorg-x11-libs-6.8.2-1.EL.13.6
xorg-x11-deprecated-libs-6.8.2-1.EL.13.6
xorg-x11-libs-6.8.2-1.EL.13.6
compat-libstdc++-33-3.2.3-47.3
compat-libstdc++-296-2.96-132.7.2
libstdc++-3.4.3-22.1
libstdc++-devel-3.4.3-22.1


--sql server2000中文与db2中文问题
sql server中一个中文的长度为1
db2 中utf-8为3,gbk为2
做转换时有中文的要注意

[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/11419868/viewspace-1020131/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/11419868/viewspace-1020131/

IBM may not offer the products, services, or features discussed in this document in other countries. Consult your local IBM representative for information on the products and services currently available in your area. Any reference to an IBM product, program, or service is not intended to state or imply that only that IBM product, program, or service may be used. Any functionally equivalent product, program, or service that does not infringe any IBM intellectual property right may be used instead. However, it is the user's responsibility to evaluate and verify the operation of any non-IBM product, program, or service. IBM may have patents or pending patent applications covering subject matter described in this document. The furnishing of this document does not give you any license to these patents. You can send license inquiries, in writing, to: IBM Director of Licensing, IBM Corporation, North Castle Drive, Armonk, NY 10504-1785 U.S.A. The following paragraph does not apply to the United Kingdom or any other country where such provisions are inconsistent with local law: INTERNATIONAL BUSINESS MACHINES CORPORATION PROVIDES THIS PUBLICATION "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Some states do not allow disclaimer of express or implied warranties in certain transactions, therefore, this statement may not apply to you. This information could include technical inaccuracies or typographical errors. Changes are periodically made to the information herein; these changes will be incorporated in new editions of the publication. IBM may make improvements and/or changes in the product(s) and/or the program(s) described in this publication at any time without notice. Any references in this information to non-IBM Web sites are provided for convenience only and do not in any manner serve as an endorsement of those Web sites. The materials at those Web sites are not part of the materials for this IBM product and use of those Web sites is at your own risk. IBM may use or distribute any of the information you supply in any way it believes appropriate without incurring any obligation to you. Information concerning non-IBM products was obtained from the suppliers of those products, their published announcements or other publicly available sources. IBM has not tested those products and cannot confirm the accuracy of performance, compatibility or any other claims related to non-IBM products. Questions on the capabilities of non-IBM products should be addressed to the suppliers of those products. This information contains examples of data and reports used in daily business operations. To illustrate them as completely as possible, the examples include the names of individuals, companies, brands, and products. All of these names are fictitious and any similarity to the names and addresses used by an actual business enterprise is entirely coincidental. COPYRIGHT LICENSE: This information contains sample application programs in source language, which illustrate
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值