Timesten學習2
1 測試使用Cache Connect to Oracle
1.1 Setting up TimesTen and Oracle
1.1.1 設定TimesTen的環境變數
[root@server1 ~]#
su - tt
[tt@server1 ~]$
cat .bash_profile
# .bash_profile
# Get the aliases
and functions
if [ -f ~/.bashrc
]; then
. ~/.bashrc
fi
# User specific
environment and startup programs
export
TimesTen=/oracle/timesten/TimesTen/tt70
export
ORACLE_HOME=/oracle/app/oracle/product/10.2.0/db_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:ORACLE_HOME/network/lib:ORACLE_HOME/oracm/lib:/lib:/usr/lib:/usr/local/lib
PATH=$PATH:$HOME/bin:/oracle/timesten/TimesTen/tt70/bin:$ORACLE_HOME/bin
export PATH
unset USERNAME
在這裡要注意要設定$ORACLE_HOME,確保timesten使用者能連線資料庫
[tt@server1 ~]$
sqlplus
SQL*Plus: Release
10.2.0.3.0 - Production on Tue Feb 10 07:50:00 2009
Copyright (c)
1982, 2006, Oracle. All Rights
Reserved.
Connected to:
Oracle Database
10g Enterprise Edition Release 10.2.0.3.0 - Production
With the
Partitioning, Real Application Clusters and Data Mining options
SQL>
1.1.2 建立一個DSN
在這裡一定要注意字符集的設定
#####################################################################
# Test Cache
Oracle Data
#####################################################################
[CacheOracleData]
Driver=/oracle/timesten/TimesTen/tt70/lib/libtten.so
DataStore=/oracle/timesten/peyton/TempDs
AutoCreate=1
Logging=1
LogPurge=1
PermSize=16
TempSize=16
UID=scott
OracleId=orcl1
OraclePwd=tiger
DatabaseCharacterSet=ZHS16GBK
ConnectionCharacterSet=ZHS16GBK
1.1.3 建立一個TimesTen使用者
ttIsql
CacheOracleData
Command>CREATE
USER scott IDENTIFIED BY 'tiger';
Command>GRANT ADMIN, DDL TO scott;
1.2 Creating a READONLY cache group
1.2.1 Create an Oracle table
sqlplus scottt/tiger@orcl1
SQL> CREATE
TABLE readtab (a NUMBER(10,0) NOT NULL PRIMARY KEY,b CHAR(31));
SQL> INSERT
INTO readtab VALUES (1, 'hello');
SQL> INSERT
INTO readtab VALUES (2, 'world');
SQL> COMMIT;
1.2.2 Create a READONLY cache group
[tt@server1 ~]$
ttIsql CacheOracleData
Copyright (c)
1996-2008, Oracle. All rights reserved.
Type ? or
"help" for help, type "exit" to quit ttIsql.
All commands must
end with a semicolon character.
connect
"DSN=CacheOracleData";
Enter password for
'scott':
Connection
successful:
DSN=CacheOracleData;UID=scott;DataStore=/oracle/timesten/peyton/TempDs;DatabaseCharacterSet=ZHS16GBK;ConnectionCharacterSet=US7ASCII;DRIVER=/oracle/timesten/TimesTen/tt70/lib/libtten.so;OracleId=orcl1;PermSize=16;TempSize=16;TypeMode=0;
(Default setting
AutoCommit=1)
Command> call
ttCacheUidPwdSet('scott','tiger');
Command> call
ttCacheStart();
Command>
CREATE READONLY CACHE GROUP readcache AUTOREFRESH INTERVAL 5 SECONDS FROM
readtab (a INT NOT NULL PRIMARY KEY, b CHAR(31));
5062: gv$session could not be found on
Oracle. Check that scott has SELECT privileges on gv$session
The
command failed.
在這裡報了一個錯,由於我是rac環境,這裡單獨在SQL裡又設定
SQL>
grant select any dictionary to scott;
Command> CREATE
READONLY CACHE GROUP readcache AUTOREFRESH INTERVAL 5 SECONDS FROM readtab (a
INT NOT NULL PRIMARY KEY, b CHAR(31));
1.2.3 Load the cache group
Command> LOAD
CACHE GROUP readcache COMMIT EVERY 30 ROWS;
Command>
cachegroups;
Cache Group
SCOTT.READCACHE:
Cache Group Type: Read Only
Autorefresh: Yes
Autorefresh Mode: Incremental
Autorefresh State: On
Autorefresh Interval: 5 Seconds
Root Table: SCOTT.READTAB
Table Type: Read Only
1 cache group
found.
1.2.4 Update the Oracle table
SQL> connect
scott/tiger@orcl1
SQL> INSERT
INTO readtab VALUES (3, 'Hello');
SQL> INSERT
INTO readtab VALUES (4, 'Again');
SQL> commit;
Oracle. Check the
contents of the READTAB table in ttIsql:
Command> SELECT
* FROM readtab;
< 1, hello >
< 2, world >
< 3, Hello >
< 4, Again >
4 rows found.
Command> insert
into readtab values (5,'bb');
8225: Table READTAB is read only
The command
failed.
Attempts
to update a cached table in a READONLY cache group result in
TimesTen
error 8225 “Table is read only”. However, if the PassThrough
attribute
is set to either 2 or 3, DML statements may be passed through the cache
to Oracle
and then propagated by AUTOREFRESH back into the cache group
from
Oracle.
Command>
autocommit 0;
Command> set
passthrough 2;
Command> delete
from readtab where a = 5;
1 row deleted.
Command>
commit;
SQL> select *
from readtab;
A B
----------
-------------------------------
1 hello
2 world
3 Hello
4 Again
1.2.5
Stop the
cache agent
Command> call ttCacheStop();
[@more@]來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/48010/viewspace-1017308/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Timesten學習1
- TimesTen學習(三)遠端連線TimesTen資料庫資料庫
- Timesten學習3(高可用性)
- TimesTen學習(四)Data Manager守護程式
- TimesTen學習(二)連線建立第一個資料庫資料庫
- Docker學習2Docker
- flask學習2Flask
- Qt學習2QT
- CGAL——學習2
- 棧學習(2)
- php學習(2)PHP
- 學習perl(2)
- HTML學習-2HTML
- css學習2CSS
- 強化學習-學習筆記2 | 價值學習強化學習筆記
- Step by Step TimesTen-- 使用ODBC訪問TimesTen資料庫C++篇(一個例子)(2)資料庫C++
- Java ASM學習(2)JavaASM
- Python學習(2)Python
- Qt學習之路2QT
- ruby 字串學習2字串
- 4/2學習程序
- 【caffe2從頭學】:2.學習caffe2
- shell學習總結-2
- RxJava2 學習(一)RxJava
- RxJava2 學習(二)RxJava
- Vue學習筆記2Vue筆記
- MySQL學習筆記2MySql筆記
- RocketMQ學習筆記 2MQ筆記
- C++學習篇(2)C++
- jQuery學習(2)ajax()使用jQuery
- Oracle學習筆記2Oracle筆記
- react學習筆記2React筆記
- 【Struts2框架學習】框架
- mysql學習筆記-2MySql筆記
- jQuery學習筆記(2)jQuery筆記
- Android NDK學習(2)Android
- php學習基礎(2)PHP
- 深入學習golang(2)—channelGolang