Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Current Events
Join our developers event to win one of the valuable prizes!
posted 4 years ago
viewed 8397 times
Share this article

CSQL - Command Line SQL Interpreter

I decided to update this CSQL Interpreter Tutorial to make it clearer why it is a must-know tool for database administrators.

Once a user has installed CUBRID database server on their machine, the first thing they need to do is to connect to the database server, and then create the necessary databases, table, and so forth. There are several ways for CUBRID users to establish the successful database connection. First, you can use CUBRID Manager, a GUI database administration tool. Second, there are various third party applications such as Eclipse QuantumDB plug-in which you can also use just like CM (CUBRID Manager) to administer your databases. QuantumDB connects to CUBRID using JDBC driver. To learn more about third party applications, read CUBRID Administration Tools. Third, and the classic way to create and manage the databases, alter tables and grand user permissions, and briefly everything else you can handle with CSQL – a command line SQL interpreter. So, today we will talk about CSQL.

What is CSQL?

As I have already mentioned CSQL is a command line tool to administer CUBRID database server and run SQL statements. It is a basic path through which a user can communicate with CUBRID.

Why CSQL?

CSQL is mainly used for the following two purposes:

  1. To execute SQL commands.
  2. As a path for receiving tasks performed by a DBA for administration.

While the first purpose can be satisfied using the various 3rd party tools, the second purpose can only be achieved using CSQL provided solely for CUBRID.

What is the difference between CSQL and CUBRID Manager clients, or other various 3rd party tools?

CSQL connects to the DB without going through the Broker. For this reason, any problems occurring in the Broker will not affect the CSQL connection at all.

Now, let's look at the basic approach of connecting to CUBRID using CSQL.

First, in order to connect to any CUBRID database we have to use csql command with a given user account (if any) and a database name.

Shell > csql database_name

CSQL provides many options you can use when launching it. For details on these options, see CSQL Startup Options.

Shell > csql demodb

This is how a user has to connect to demodb, a demonstration database provided by default in CUBRID DBMS with the public account (empty password). When you connect to a database, you will see the following window.

sql_interpreter1.jpg

At any time in order to learn what command you have to run for in certain cases, you type ;help command. There are several rules when running CSQL commands.

  1. All CSQL commands must come after a semi-colon (;). For instance, in order to request help, you type ;help.
  2. After executing any query, go to a new line and execute ;x or ;ru to see the result.

    1. ;x deletes the query in the buffer after execution,
    2. while ;ru leaves the query in the buffer to be reused later after the execution.
  3. To reuse queries, use ;edit. This will start a vi editor, where you will see the queries that have been executed previously.

CSQL is a very powerful command line interpreter. You are recommended to read our online Wiki CSQL Interpreter Tutorial. You will learn about reading, saving, and appending SQL statement, Shell command execution/registration, transaction processing, outputting schema information/syntax rules and examples, parameter setting, etc, which are beyond those provided by CUBRID Manager or other simple query editor tools.

If you have any questions regarding CSQL, please post them on our CUBRID Forum.

If you want to be up to date and learn more about CUBRID, subscribe to our CUBRID Blog or CUBRID Trainings Channel, follow us on Facebook or Twitter.  We will make sure you are up to date with every news and updates about CUBRID.



comments powered by Disqus