ttisql类似于sqlplus,趁着学习Times Ten的时间,积累下ttisql的指令,方便以后查看。
1.进入ttisql
C:\Users\lion>ttisql Copyright (c) 1996-2011, Oracle. All rights reserved. Type ? or "help" for help, type "exit" to quit ttIsql.
2.连接Times Ten dsn
Command> connect "dsn=myTT"; Connection successful: DSN=myTT;UID=lion;DataStore=D:\oracle\timesten\odbc;Datab aseCharacterSet=AL32UTF8;ConnectionCharacterSet=AL32UTF8;Temporary=1;DRIVER=D:\o racle\timesten\bin\ttdv1122.dll;LogDir=D:\oracle\timesten\log;TypeMode=0;PLSCOPE _SETTINGS=IDENTIFIERS:NONE;DDLReplicationLevel=1; (Default setting AutoCommit=1) Command>
3.运行sql文件
Command> run e:\create.sql; CREATE TABLE student ( id NUMBER NOT NULL PRIMARY KEY, name varchar2(64), age NUMBER );
4.断开连接
Command> exit Disconnecting... Done.
5.设置是否自动提交
Command> autocommit 0;
6.查看所有表
Command> alltables; SYS.ACCESS$ SYS.ARGUMENT$ SYS.CACHE_GROUP SYS.COLUMNS SYS.COLUMN_HISTORY SYS.COL_STATS SYS.DEPENDENCY$ SYS.DIR$ SYS.DUAL SYS.ERROR$ SYS.IDL_CHAR$ SYS.IDL_SB4$ SYS.IDL_UB1$ SYS.IDL_UB2$ SYS.INDEXES SYS.MONITOR ... 59 tables found.
7.查看记录
Command> h; 8 INSERT INTO T3 VALUES (3) 9 INSERT INTO T1 VALUES (4) 10 INSERT INTO T2 VALUES (5) 11 INSERT INTO T3 VALUES (6) 12 autocommit 0 13 showplan 14 SELECT * FROM T1, t2, t3 WHERE A=B AND B=C AND A=B 15 trytbllocks 0 16 tryserial 0 17 SELECT * FROM T1, t2, t3 WHERE A=B AND B=C AND A=B Command>
8.保存历史记录到文件
Command> savehistory history.txt;
9.如果历史文件保存时提示文件已存在可以使用-a来覆写重名文件
Command> savehistory -a history.txt;
10.清空历史记录
Command> clearhistory;
11.查看表信息
Command> describe student; Table LION.STUDENT: Columns: *ID NUMBER NOT NULL NAME VARCHAR2 (64) INLINE AGE NUMBER 1 table found. (primary key columns are indicated with *)
12.插入一条记录
Command> insert into lion.student values(1,'liyongyao',24); 1 row inserted.
13.创建用户
Command> create user liyongyao identified by ttdb; User created.
14.使用cachegroups命令
官方对cachegroups这个命令是这样解释的:
The cachegroups command is used to provide detailed information on cache groups defined in the current database. The attributes of the root and child tables defined in the cache group are displayed in addition to the WHERE clauses associated with the cache group. The argument to the cachegroups command is the name of the cache group that you want to display information for.
目前这个还没有研究明白,暂时先保存下来,以后弄清楚了更新。
Command> cachegroups; Cache Group CACHEUSER.READCACHE: Cache Group Type: Read Only Autorefresh: Yes Autorefresh Mode: Incremental Autorefresh State: Paused Autorefresh Interval: 5 Seconds Autorefresh Status: ok Aging: No aging defined Root Table: ORATT.READTAB Table Type: Read Only Cache Group CACHEUSER.WRITECACHE: Cache Group Type: Asynchronous Writethrough global (Dynamic) Autorefresh: No Aging: LRU on Root Table: ORATT.WRITETAB Table Type: Propagate 2 cache groups found.
15.查看当前正在使用的数据库分配内存状态、永久和临时分区大小以及最大值
Command> dssize; PERM_ALLOCATED_SIZE: 32768 PERM_IN_USE_SIZE: 9013 PERM_IN_USE_HIGH_WATER: 9013 TEMP_ALLOCATED_SIZE: 40960 TEMP_IN_USE_SIZE: 11179 TEMP_IN_USE_HIGH_WATER: 14470
16.使用tablesize命令
命令格式:
tablesize [[owner_name_pattern.]table_name_pattern]
这个命令将显示详细的分析表的空间使用量。先执行ttComputeTabSizes内置程序,分析过表空间使用量等数据后,再使用tablesize命令显示数据分析。
Command> call ttComputeTabSizes('student'); Command> tablesize student; Sizes of LION.STUDENT: INLINE_ALLOC_BYTES: 37920 NUM_USED_ROWS: 1 NUM_FREE_ROWS: 255 AVG_ROW_LEN: 153 OUT_OF_LINE_BYTES: 0 METADATA_BYTES: 1296 TOTAL_BYTES: 39216 LAST_UPDATED: 2013-05-23 19:31:37.000000 1 table found.
17.使用监控命令
监视命令显示所有自上次数据库加载到内存之后提供的信息。这个命令比dssize命令提供更多的信息。除了dssize命令提供的信息之外还包括连接数量统计,检查点,锁超时,提交,回滚和其他信息。
Command> monitor; TIME_OF_1ST_CONNECT: Thu May 23 17:03:21 2 DS_CONNECTS: 13 DS_DISCONNECTS: 1 DS_CHECKPOINTS: 17 DS_CHECKPOINTS_FUZZY: 16 DS_COMPACTS: 0 PERM_ALLOCATED_SIZE: 32768 PERM_IN_USE_SIZE: 9036 PERM_IN_USE_HIGH_WATER: 9036 TEMP_ALLOCATED_SIZE: 40960 TEMP_IN_USE_SIZE: 11306 TEMP_IN_USE_HIGH_WATER: 14470 SYS18: 0 TPL_FETCHES: 0 TPL_EXECS: 0 CACHE_HITS: 0 PASSTHROUGH_COUNT: 0 XACT_BEGINS: 451 XACT_COMMITS: 450 XACT_D_COMMITS: 0 XACT_ROLLBACKS: 0 LOG_FORCES: 5 DEADLOCKS: 0 LOCK_TIMEOUTS: 0 LOCK_GRANTS_IMMED: 120362 LOCK_GRANTS_WAIT: 0 SYS19: 0 CMD_PREPARES: 33 CMD_REPREPARES: 0 CMD_TEMP_INDEXES: 0 LAST_LOG_FILE: 0 REPHOLD_LOG_FILE: -1 REPHOLD_LOG_OFF: -1 REP_XACT_COUNT: 0 REP_CONFLICT_COUNT: 0 REP_PEER_CONNECTIONS: 0 REP_PEER_RETRIES: 0 FIRST_LOG_FILE: 0 LOG_BYTES_TO_LOG_BUFFER: 8777728 LOG_FS_READS: 0 LOG_FS_WRITES: 23 LOG_BUFFER_WAITS: 0 CHECKPOINT_BYTES_WRITTEN: 0 CURSOR_OPENS: 362 CURSOR_CLOSES: 362 SYS3: 0 SYS4: 0 SYS5: 0 SYS6: 0 CHECKPOINT_BLOCKS_WRITTEN: 0 CHECKPOINT_WRITES: 0 REQUIRED_RECOVERY: 0 SYS11: 0 SYS12: 1 TYPE_MODE: 0 SYS13: 0 SYS14: 0 SYS15: 0 SYS16: 0 SYS17: 0 SYS9:
18.查看数据库对象列表。
tables and alltables - Lists tables indexes and allindexes - Lists indexes views and allviews - Lists views sequences and allsequences - Lists sequences synonyms and allsynonyms - Lists synonyms functions and allfunctions - Lists PL/SQL functions procedures and allprocedures - Lists PL/SQL procedures packages and allpackages - Lists PL/SQL packages
未完待续...