The CSQL Interpreter is the command line-based SQL Interpreter. It allows you to create a SQL query, retrieve execution result, and save the SQL query and its result into a file for later use. In addition, it can print the execution result or display it page by page on a screen. Thus:

Supports all terminal environments without X Windows

Can be used to enter, edit, and execute all CUBRID commands

Outputs the result to a file or screen

Connecting to a Database

The CSQL Interpreter allows to connect to both local and remote database hosts.

Connecting to a local database

The syntax used to connect to a local host in the command line using the CSQL Interpreter is shown below:

csql [options list] database_name

In other words, you can connect to the demodb database using CSQL by entering the followings in the shell prompt. (The demodb database is the default demo database installed automatically with CUBRID.)

> csql demodb

Connecting to a remote database

To connect to a remote database using the CSQL Interpreter, you need to enter the remote database information in the databases.txt configuration file located in the databases directory under the CUBRID installation directory (the environment variable which stores the location is $CUBRID_DATABASES).

CSQL Session Commands

Command Syntax

In addition to SQL statements, CSQL Interpreter provides special commands allowing you to control the Interpreter. These commands are called session commands. All the session commands must start with a semicolon (;). Enter the ';help' command in the CSQL Interpreter to display a list of the session commands available. Note that only the uppercase letters of each session command are required to make the CSQL Interpreter recognize it and not case sensitive.

This command displays the list that contains previously executed commands (input) and their history numbers.

;HISTORYR ead history_num

Moves input with the specified history number into the buffer.

;HE lp

Displays all of the CSQL session commands.

Basic Examples of Session Commands

Default Screen

When the CSQL is executed, the following information is displayed on the screen.

CUBRID SQL Interpreter
Type `;help' for help messages.
csql

Examples

You can use the read command, which reads an input file into a buffer, to check the contents of the input file. The list command displays the contents of a buffer and the edit command modifies the contents of a buffer.

First, create a table with the schema creation command. Just type the new schema information of the new table, once completed, type ;x and hit enter to execute the SQL statement you have just written. This will execute the SQL statement in the buffer and also deletes the contents of the buffer.

Then, use ';sc table_name' to check the details of the newly created table.

If the -noac (no auto-commit) option was used when starting CSQL, all the transactions till now, e.g. entering, deleting, or changing schema or data, must be reflected on the database using the ;co (commit) or ;ro (rollback) command before termination. If you exit without reflecting the transactions on the database, the system will ask whether you want to reflect it or not.