之前有介绍过ODB工具的基本介绍,该篇文章介绍的是ODB工具的常见用法
[root@test01 oracle]# odb64luo -h odb version 1.1.0 Build: linux, amd64, gcc generic m64, uodbc, mreadline, dynamic gzip, dynamic libhdfs, dynamic libxml2 [Jul 14 2020 05:24:25] -h: print this help -version: print odb version and exit -lsdrv: list available drivers @ Driver Manager level -lsdsn: list available Data Sources Connection related options. You can connect using either: ......
-u:指定数据库用户名
-p:指定数据库用户名对应的密码
-d:指定ODBC配置中连接数据库的名称
-i:连接ODBC详细信息,-i后可以指定其他参数,如:-i 后指定EsgynDB数据库中的schema名字,结果返回schema下的表名列表
[root@test01 ~]# odb64luo -u db__root -p traf123 -d traf -i
odb [2020-12-23 17:35:35]: starting ODBC connection(s)... 0
[odb version 1.1.0]
Build: linux, amd64, gcc generic m64, uodbc, mreadline, dynamic gzip, dynamic libhdfs, dynamic libxml2 [Jul 14 2020 05:24:25]
DBMS product name (SQL_DBMS_NAME) : Trafodion
DBMS product version (SQL_DBMS_VER) : 02.07.0002
Database name (SQL_DATABASE_NAME) : TRAFODION
Server name (SQL_SERVER_NAME) : test03($Z00010001EQ){TCP:10.12.40.13/23422:ODBC}
Data source name (SQL_DATA_SOURCE_NAME) : traf
Data source RO (SQL_DATA_SOURCE_READ_ONLY) : N
ODBC Driver name (SQL_DRIVER_NAME) : libtrafodbc64.so
ODBC Driver version (SQL_DRIVER_VER) : 03.00.0000
ODBC Driver level (SQL_DRIVER_ODBC_VER) : 03.51
ODBC Driver Manager version (SQL_DM_VER) : 03.52.0002.0003
ODBC Driver Manager level (SQL_ODBC_VER) : 03.52
Connection Packet Size (SQL_ATTR_PACKET_SIZE): 0
odb [2020-12-23 17:35:36]: exiting. Session Elapsed time 0.407 seconds (00:00:00.407)
-I:指定通过交互模式访问数据库
[root@test01 oracle]# odb64luo -u db__root -p traf123 -d traf -I odb version 1.1.0 - SQL Interpreter Mode Build: linux, amd64, gcc generic m64, uodbc, mreadline, dynamic gzip, dynamic libhdfs, dynamic libxml2 [Jul 14 2020 05:24:25] odb [2020-12-23 17:48:50]: starting ODBC connection(s)... 0 Connected to Trafodion odb [main(1858)] - Warning. Cannot open ODB_INI file (/root/.odbrc): [2] No such file or directory SQL> SQL> create table test_t1(a int,b varchar(20)); --- command executed in 3.600s (prep 0.002s, exec 3.598s, fetch 0.000s/0.000s) SQL> SQL> insert into test_t1 values(1,'aaa'),(2,'kkk'); --- 2 row(s) inserted in 0.662s (prep 0.627s, exec 0.035s, fetch 0.000s/0.000s) SQL> SQL> select * from test_t1; 1,aaa 2,kkk --- 2 row(s) selected in 0.007s (prep 0.005s, exec 0.001s, fetch 0.001s/0.001s) SQL>
-x:指定通过命令行方式执行SQL语句
[root@test01 oracle]# odb64luo -u db__root -p traf123 -d traf -x "select * from test_t1" odb [2020-12-23 17:53:46]: starting ODBC connection(s)... 0 1,aaa 2,kkk [0.0.0]--- 2 row(s) selected in 0.004s (prep 0.001s, exec 0.002s, fetch 0.001s/0.001s) odb [2020-12-23 17:53:47]: exiting. Session Elapsed time 0.401 seconds (00:00:00.401) [root@test01 oracle]#
-l:将数据文件导入EsgynDB,可以是本地文件、hdfs文件或者其他远程文件
src:指定数据数据源,即数据文件名,可以是文件的绝对路径,亦可以是相对路径
tgt:指定数据目标,即数据库中的表
fs:指定数据文件中数据列之间的分隔符
rows:指定多少数据量进行提交
[root@test01 ~]# odb64luo -u db__root -d traf -l src=odb_test_data.txt:tgt=trafodion.seabase.ODB_TEST:fs=,:rows=1 Password: odb [2020-12-23 14:49:48]: starting ODBC connection(s)... 0 Connected to Trafodion [0] 1 records inserted [commit] [0] 2 records inserted [commit] [0] 3 records inserted [commit] [0] odb version 1.1.0 Load(2) statistics: [0] Target table: TRAFODION.SEABASE.ODB_TEST [0] Source: odb_test_data.txt [0] Pre-loading time: 5.239 s (00:00:05.239) [0] Loading time: 0.083 s(00:00:00.083) [0] Total records read: 3 [0] Total records inserted: 3 [0] Total number of columns: 2 [0] Total bytes read: 27 [0] Average input row size: 9.0 B [0] ODBC row size: 91 B (data) + 16 B (len ind) [0] Rowset size: 1 [0] Rowset buffer size: 0.10 KiB [0] Load throughput (real data): 0.318 KiB/s [0] Load throughput (ODBC): 3.212 KiB/s odb [2020-12-23 14:49:53]: exiting. Session Elapsed time 5.328 seconds (00:00:05.328)
-cp:将异构数据库数据导入EsgynDB
src:指定数据源,即异构数据库相应表
tgt:指定数据目标,即数据库中的表
rows:指定多少数据量进行提交
[root@test01 ~]# odb64luo -u pubuser:db__root -p pubu123:123qwe -d oracle:traf -cp src="odb_t1":tgt=seabase.ODB_TEST:rows=1; Connected to Oracle odb [2020-12-23 16:04:13]: starting ODBC connection(s)... 0 >1 >2 Connected to Trafodion [1] 1 records copied [commit] [2] 1 records copied [commit] [0] odb version 1.1.0 Copy statistics: [0] Source: ODB_T1 [0] Target: seabase.ODB_TEST [0] Total number of columns: 2 [0] ODBC row size: 62 B (data) + 16 B (len ind) [0] Rowset size: 1 [0] Rowset buffer size: 0.08 KiB [0] Pre-copy time: 0.884 s (00:00:00.884) [0] Copy time: 0.034 s (00:00:00.034) [0] Total records copied: 2 (0.059 krec/s) [0] Copy throughput (ODBC): 0.003 MiB/s (0.012 GiB/h) [0] Total/Wait cycles: 2/0 [0>1] 1 records copied in 0.033 (00:00:00.033 s) [0>2] 1 records copied in 0.034 (00:00:00.034 s) odb [2020-12-23 16:04:14]: exiting. Session Elapsed time 0.943 seconds (00:00:00.943)
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69985104/viewspace-2744796/ ,如需转载,请注明出处,否则将追究法律责任。