Using ttIsql in Batch Mode or Interactive Mode

The ttIsql utility can be used in two distinctly different ways: batch mode or interactive mode.

When ttIsql is used in interactive mode, users type commands directly into ttIsql from the console. When ttIsql is used in batch mode, a prepared script of ttIsql commands is run by specifying the name of the file containing the commands.

Batch mode is commonly used for the following types of tasks:

  • Performing periodic maintenance operations including the updating of table statistics, compacting the database and purging log files.

  • Initializing a database by creating tables, indexes and cache groups and then populating the tables with data.

  • Generating simple reports by running common queries.

Interactive mode is suited for the following types of tasks:

  • Experimenting with TimesTen features, testing design alternatives and improving query performance.

  • Solving database problems by examining database statistics.

  • Any other database tasks that are not performed routinely.

By default, when starting ttIsql from the shell, ttIsql is in interactive mode. The ttIsql utility prompts you to type in a valid ttIsql built-in command or SQL statement by printing the Command> prompt. The following example starts ttIsql in interactive mode and then connects to a TimesTen database by running the connect command with the database1 DSN.

C:\>ttIsql

Copyright (c) 1996, 2024 Oracle.  All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.

Command> connect database1;
Connection successful: 
DSN=database1;DataStore=/disk1/databases/database1;DatabaseCharacterSet=AL32UTF8;
ConnectionCharacterSet=AL32UTF8;PermSize=128;
(Default setting AutoCommit=1)

Command>

When connecting to the database using ttIsql, you can also specify the DSN or connection string on the ttIsql command line. The connect command is implicitly run.

C:\>ttIsql -connstr "DSN=database1"

Copyright (c) 1996, 2024 Oracle.  All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.

connect "DSN=database1";
Connection successful: 
DSN=database1;DataStore=/disk1/databases/database1;DatabaseCharacterSet=AL32UTF8;
ConnectionCharacterSet=AL32UTF8;PermSize=128;
(Default setting AutoCommit=1)

Command>

Batch mode can be accessed in two different ways. The most common way is to specify the -f option on the ttIsql command line followed by the name of file to run.

For example, running a file containing a CREATE TABLE statement looks like the following:

C:\>ttIsql -f create.sql -connstr "DSN=database1"

Copyright (c) 1996, 2024 Oracle.  All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.

connect "DSN=database1";
Connection successful: 
DSN=database1;DataStore=/disk1/databases/database1;DatabaseCharacterSet=AL32UTF8;
ConnectionCharacterSet=AL32UTF8;PermSize=128;
(Default setting AutoCommit=1)

run "create.sql"

CREATE TABLE LOOKUP (KEY NUMBER NOT NULL PRIMARY KEY, VALUE CHAR (64))

exit;
Disconnecting...
Done.

C:\>

The other way to use batch mode is to enter the run command directly from the interactive command prompt. The run command is followed by the name of the file containing ttIsql built-in commands and SQL statements to run:

Command> run "create.sql";

CREATE TABLE LOOKUP (KEY NUMBER NOT NULL PRIMARY KEY, VALUE CHAR (64))
Command>