TimesTen如何緩存兩個用戶的Schema

3/7/2017來源:SQL技巧人氣:6025

如果Oracle數據庫中有兩張表,分別屬于不同的Schema, TimesTen是否可以緩存? 答案是可以的,來看一個例子,順便了解一下概念;

男人的天堂 AV电影首先在Oracle數據庫中建立兩個用戶user1和user2,并且分布在兩個用戶下建表t1和t2:

SQL> create user user1 identified by oracle; User created. SQL> create user user2 identified by oracle; User created. SQL> grant create session, create table to user1; Grant succeeded. SQL> grant create session, create table to user2; Grant succeeded. SQL> ALTER USER user1 quota unlimited on USERS; User altered. SQL> ALTER USER user2 quota unlimited on USERS; User altered. SQL> connect user1/oracle Connected. SQL> create table t1(k int, v int, imary key(k)); Table created. SQL> insert into t1 values(1,1); 1 row created. SQL> grant select on t1 to cacheadm; Grant succeeded. SQL> connect user2/oracle Connected. SQL> create table t2(k int, v int, primary key(k)); Table created. SQL> insert into t2 values(2,1); 1 row created. SQL> grant select on t2 to cacheadm; Grant succeeded.

在TimesTen數據庫端,也分別建立用戶user1和user2, 使用cacheadm用戶建立兩個緩存組:

Command> create user user1 identified by timesten; User created. Command> create user user2 identified by timesten; User created. Command> grant create session to user1; Command> Command> grant create session to user2; Command> cachegroups; Cache Group CACHEADM.USER1_CG: Cache Group Type: Read Only Autorefresh: Yes Autorefresh Mode: Incremental Autorefresh State: On Autorefresh Interval: 5 Seconds Autorefresh Status: ok Aging: No aging defined Root Table: USER1.T1 Table Type: Read Only Cache Group CACHEADM.USER2_CG: Cache Group Type: Read Only Autorefresh: Yes Autorefresh Mode: Incremental Autorefresh State: On Autorefresh Interval: 5 Seconds Autorefresh Status: ok Aging: No aging defined Root Table: USER2.T2 Table Type: Read Only

接下來,就可以在TimesTen中使用user1或user2訪問數據了:

[timesten@ttlab ~]$ ttisql "dsn=sampledb_1122;uid=user1" Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. Type ? or "help" for help, type "exit" to quit ttIsql. connect "dsn=sampledb_1122;uid=user1"; Enter passWord for 'user1': Connection successful: DSN=sampledb_1122;UID=user1;DataStore=/home/timesten/TimesTen/tt1122/info/DemoDataStore/sampledb_1122;DatabaseCharacterSet=WE8MSWIN1252;ConnectionCharacterSet=US7ASCII;DRIVER=/home/timesten/TimesTen/tt1122/lib/libtten.so;PermSize=40;TempSize=32;TypeMode=0;OracleNetServiceName=orcl; (Default setting AutoCommit=1) Command> select * from t1; < 1, 1 > 1 row found. Command> select * from user2.t2; 15100: User USER1 lacks privilege SELECT on USER2.T2 The command failed.

男人的天堂 AV电影總結以上的測試,如下圖:

也就是說,Oracle中表的屬主用戶,在TimesTen中也必須有此用戶。這時最關鍵的一點。

因此也建議使用獨立的緩存管理員,而非直接賦予user1或user2 CACHE_MANAGER權限。剩下的問題就靠權限解決了,你也可以基于這兩個表建立視圖。

男人的天堂 AV电影還有一個重要概念,一個TimesTen只能緩存一個Oracle數據庫,多個是不行的!



優質網站模板

  • 1
  • 2
  • 3