root用户安装时,TimesTen的配置文件为 $TimesTen_Home/info/sys.odbc.ini 文件中。下面是安装后的这个文件缺省内容:

 [tt1@west-mountain info]$ vi sys.odbc.ini 

# Copyright (C) 1999, 2007, Oracle. All rights reserved.

#########################################################################

#

# The following are the default values for connection attributes.

# In the Data Sources defined below, if the attribute is not explicitly

# set in its entry, TimesTen 7.0 uses the defaults as

# specified below.  For more information on these connection attributes,

# see the accompanying documentation.

#

# Lines in this file beginning with # or ; are treated as comments.

# In _attribute_=_value_ lines, the _value_ consists of everything

# after the = to the end of the line, with leading and trailing white

# space removed.

#

/*这一段是TimesTen的所有属性值,是我们配置的一个很好参考。*/

#########################################################################

#

#       Authenticate=1  (client/server only)

#       AutoCreate=1

#       CkptFrequency   (if Logging == 1 then 600 else 0)

#       CkptLogVolume=0

#       CkptRate=0      (0 = rate not limited)

#       ConnectionCharacterSet (if DatabaseCharacterSet == TIMESTEN8

#                               then TIMESTEN8 else US7ASCII)

#       ConnectionName  (process argv[0])

#       Connections=64

#       DatabaseCharacterSet (no default)

#       Diagnostics=1

#       DurableCommits=0

#       ForceConnect=0

#       GroupRestrict   (none by default)

#       Isolation=1     (1 = read-committed)

#       LockLevel=0     (0 = row-level locking)

#       LockWait=10     (seconds)

#       Logging=1       (1 = write log to disk)

#       LogAutoTruncate=1

#       LogBuffSize=65536 (measured in KB)

#       LogDir          (same as checkpoint directory by default)

#       LogFileSize=64  (measured in MB)

#       LogFlushMethod=0

#       LogPurge=1

#       MatchLogOpts=0

#       MemoryLock=0    (HP-UX, Linux, and Solaris platforms only)

#       NLS_LENGTH_SEMANTICS=BYTE

#       NLS_NCHAR_CONV_EXCP=0

#       NLS_SORT=BINARY

#       OverWrite=0

#       PermSize=2      (measured in MB; default is 2 on 32-bit, 4 on 64-bit)

#       PermWarnThreshold=90

#       Preallocate=0

#       PrivateCommands=0

#       PWD             (no default)

#       PWDCrypt        (no default)

#       RecoveryThreads=1

#       SQLQueryTimeout=0 (seconds)

#       Temporary=0     (data store is permanent by default)

#       TempSize        (measured in MB; default is derived from PermSize,

#                        but is always at least 6MB)

#       TempWarnThreshold=90

#       TypeMode=0      (0 = Oracle types)

#       UID             (operating system user ID)

#       WaitForConnect=1

#

# Oracle Loading Attributes

#       OracleID        (no default)

#       OraclePWD       (no default)

#       PassThrough=0   (0 = SQL not passed through to Oracle)

#       RACCallback=1

#       TransparentLoad=0 (0 = do not load data)

#

# Client Connection Attributes

#       ConnectionCharacterSet (if DatabaseCharacterSet == TIMESTEN8

#                               then TIMESTEN8 else US7ASCII)

#       ConnectionName  (process argv[0])

#       PWD             (no default)

#       PWDCrypt        (no default)

#       TTC_Server      (no default)

#       TTC_Server_DSN  (no default)

#       TTC_Timeout=60

#       UID             (operating system user ID)

#

#########################################################################

/*每个ODBC数据源的驱动器的类型说明,是直连(Direct)还是C/S模式*/

[ODBC Data Sources]

TT_tt70=TimesTen 7.0 Driver

TpcbData_tt70=TimesTen 7.0 Driver

TptbmDataRepSrc_tt70=TimesTen 7.0 Driver

TptbmDataRepDst_tt70=TimesTen 7.0 Driver

TptbmData_tt70=TimesTen 7.0 Driver

BulkInsData_tt70=TimesTen 7.0 Driver

WiscData_tt70=TimesTen 7.0 Driver

RunData_tt70=TimesTen 7.0 Driver

CacheData_tt70=TimesTen 7.0 Driver

TpcbDataCS_tt70=TimesTen 7.0 Client Driver

TptbmDataCS_tt70=TimesTen 7.0 Client Driver

BulkInsDataCS_tt70=TimesTen 7.0 Client Driver

WiscDataCS_tt70=TimesTen 7.0 Client Driver

RunDataCS_tt70=TimesTen 7.0 Client Driver

#####################################################################

# Instance-Specific System Data Store

#

# A predefined instance-specific data store reserved for system use.

# It provides a well-known data store for use when a connection

# is required to execute commands.

#

#####################################################################

/*这个往下是具体的DataStore的配置,已经配好的是TimesTenDemo程序要用到的DataStore*/

[TT_tt70]

Driver=/home/tt1/TimesTen/tt70/lib/libtten.so

DataStore=/home/tt1/TimesTen/tt70/info/TT_tt70

DatabaseCharacterSet=US7ASCII

。。。。。。

  

下面我们配置一个测试用的DataStore,当然你也可以直接连接已经配置好的DataStore

 

 [dsa]  /*命名为dsa,即DataStore A*/

Driver=/home/tt1/TimesTen/tt70/lib/libtten.so   /*每个安装对应的该 so 文件是固定的*/

DataStore=/home/tt1/TimesTen/tt70/info/dsa           /*可以设置为自己的目录,但必须有相应的写权限*/

DatabaseCharacterSet=ZHS16GBK

PermSize=50

TempSize=10

 

下面我们通过TimesTen的交互式命令 ttisql (类似与OracleSqlplus)来连接到刚创建的dsa

 [tt1@west-mountain info]$ ttisql dsa 

Copyright (c) 1996-2007, Oracle.  All rights reserved.

Type ? or "help" for help, type "exit" to quit ttIsql.

All commands must end with a semicolon character.

connect "DSN=dsa";

Connection successful: DSN=dsa;UID=tt1;DataStore…;TypeMode=0;

(Default setting AutoCommit=1)

 

可以看到已经正常登录,并显示了相关参数的值,如用户名、DSNDataStore Name)、存储的路径、数据库字符集等。现在可以通过ttisql来访问和操纵TimesTen了,先执行一条命令tables,注意TimesTen的命令必须以分号结束:

 Command> tables;

  SYS.CACHE_GROUP

  SYS.COLUMNS

  SYS.COLUMN_HISTORY

  SYS.COL_STATS

  SYS.DUAL

  SYS.INDEXES

  SYS.MONITOR

  SYS.OBJ_ACC_RIGHT

  SYS.PLAN

  SYS.SEQUENCES

  SYS.SYNONYMS

  SYS.SYS_ACC_RIGHT

  SYS.TABLES

  SYS.TABLE_HISTORY

  SYS.TBL_STATS

  SYS.TCOL_STATS

  SYS.TINDEXES

  SYS.TRANSACTION_LOG_API

  SYS.TTABLES

  SYS.TTBL_STATS

  SYS.USERS

  SYS.VIEWS

  SYS.XLASUBSCRIPTIONS

  TTREP.REPELEMENTS

  TTREP.REPLICATIONS

  TTREP.REPNETWORK

  TTREP.REPPEERS

  TTREP.REPSTORES

  TTREP.REPSUBSCRIPTIONS

  TTREP.REPTABLES

  TTREP.TTSTORES

31 tables found.

 

这就是TimesTen的所有系统表了。试试表的建立,数据插入,检索、删除等操作:

Command> create table ftable(id int not null primary key, name char(10));Command> desc ftable; 

Table TT1.FTABLE:

  Columns:

   *ID                              NUMBER (38) NOT NULL

    NAME                            CHAR (10)

1 table found.

(primary key columns are indicated with *)

 Command> insert into ftable values(1,’hello’);

1 row inserted.

Command> insert into ftable values(2,’world’);

1 row inserted.

Command> commit;Command> select * from ftable;

< 1, hello      >

< 2, world      >

2 rows found.

Command> drop table ftable;  TimesTen的大部分语法和Oracle的相似,后面陆续介绍。

一个回复 “TimesTen for Linux使用指南(2) - DataStore配置及登录”

  1. TimesTen » Blog Archive » TimesTen 初学者学习路线图 说:

    [...] 创建数据源 [...]

留言