Background Image

Are you new around here?

Don't worry, it's easy to get started with CUBRID.

Picking up new things might not always be easy. But with the step-by-step CUBRID guides, you can get started right away.
Just pick one option and follow the simple instructions below.

 

  • LINUX
  • WINDOWS
    • Installing and Running CUBRID
    • Creating Database
    • Running SQL with CSQL
    • JDBC Programming
    • Installing and Running CUBRID (Linux)

      The installation program consists of shell scripts that contain binary; thus it can be installed automatically.
      The following example shows how to install CUBRID on Linux.

      > chmod +x CUBRID-major_version.minor_version-latest-Linux.x86_64.sh
      > ./CUBRID-major_version.minor_version-latest-Linux.x86_64.sh
      ...
      Do you accept the license? [yN]: y
      By default the CUBRID will be installed in:
        "/home/cubrid/CUBRID-major_version.minor_version.patch_version.serial_number-hash_tag-Linux.x86_64"
      Do you want to include the subdirectory CUBRID-major_version.minor_version.patch_version.serial_number-hash_tag-Linux.x86_64?
      Saying no will install in: "/home/cubrid" [Yn]: y
      Using target directory: /home/cubrid/CUBRID-major_version.minor_version.patch_version.serial_number-hash_tag-Linux.x86_64
      Since CUBRID broker and server versions should match, please make sure that you are running the same version if you operate them in separate machines.
      Do you want to continue? [Yn] : y
      Extracting, please wait...
      Unpacking finished successfully
      demodb has been successfully created.
      If you want to use CUBRID, run the following command to set required environment variables.
      (or you can add the command into your current shell profile file to set permanently)
        > . /home/cubrid/.cubrid.sh
                      

      The CUBRID related environment variables must be set in order to use the CUBRID database.

      > . $HOME/.cubrid.sh

      After CUBRID is installed, you can check the installed CUBRID version as follows.

      > cubrid_rel
      CUBRID major_version.minor_version (major_version.minor_version.patch_version.serial_number-hash_tag) (64bit release build for Linux) (__DATE__ __TIME__)
      				        

      You can start CUBRID master, CUBRID broker and CUBRID Manager server as follows.

      > cubrid service start
      @ cubrid master start
      ++ cubrid master start: success
      @ cubrid broker start
      ++ cubrid broker start: success
      @ cubrid manager server start
      ++ cubrid manager server start: success

      The database server does not start automatically by default.
      You can start demodb, which is created by default as follows.

      > cubrid server start demodb
      @ cubrid server start: demodb
      This may take a long time depending on the amount of recovery works to do.
      CUBRID major_version.minor_version
      ++ cubrid server start: success

      The following example shows how to check the status of master process and database server registered.

      > cubrid service status
      @ cubrid master status
      ++ cubrid master is running.
      @ cubrid server status
      Server demodb (rel major_version.minor_version, pid 9738)
      @ cubrid broker status
      NAME                   PID  PORT    AS   JQ                  TPS                  QPS   SELECT   INSERT   UPDATE   DELETE   OTHERS     LONG-T     LONG-Q         ERR-Q  UNIQUE-ERR-Q  #CONNECT   #REJECT
      ===========================================================================================================================================================================================================
      * query_editor          9672 30000     5    0                    0                    0        0        0        0        0        0     0/60.0     0/60.0             0             0         0         0
      * broker1               9683 33000     5    0                    0                    0        0        0        0        0        0     0/60.0     0/60.0             0             0         0         0
      @ cubrid manager server status
      ++ cubrid manager server is running.
      						
    • Creating Database

      The following example shows how to create a new database.

      > mkdir $CUBRID_DATABASES/testdb
      > cubrid createdb -F $CUBRID_DATABASES/testdb -v testdb en_US
      Creating database with 512.0M size using locale en_US. The total amount of disk space needed is 1.5G.
      CUBRID 10.2
                      

      When creating a new database, the following files are created by default.

      > ls -al $CUBRID_DATABASES/testdb
      total 1050264
      drwxrwxr-x. 3 cubrid cubrid       110 Mar 17 00:39 .
      drwxrwxr-x. 4 cubrid cubrid        55 Mar 17 00:39 ..
      drwxrwxr-x. 2 cubrid cubrid         6 Mar 17 00:39 lob
      -rw-------. 1 cubrid cubrid 536870912 Mar 17 00:39 testdb
      -rw-------. 1 cubrid cubrid 536870912 Mar 17 00:39 testdb_lgar_t
      -rw-------. 1 cubrid cubrid 536870912 Mar 17 00:39 testdb_lgat
      -rw-------. 1 cubrid cubrid       276 Mar 17 00:39 testdb_lginf
      -rw-------. 1 cubrid cubrid       433 Mar 17 00:39 testdb_vinf
    • Running SQL with CSQL

      The CSQL Interpreter is an application that is installed with CUBRID.
      It can directly connect to the CUBRID database and perform various operations using SQL statements.

      You can connect directly to the CUBRID database with the CSQL Interpreter as follows.

      > csql -u dba demodb
          CUBRID SQL Interpreter
      Type `;help' for help messages.
      csql> 

      The following SQL shows a list of all databases that exist in the directory file ($CUBRID_DATABASES/databases.txt).

      csql> SELECT list_dbs();
         list_dbs()
      ======================
      'testdb demodb'

      The following SQL shows the connected database name and user name.

      csql> SELECT database(), CURRENT_USER;
         database()            CURRENT_USER
      ============================================
      'demodb'              'DBA'

      The following SQL shows the list of all table names in the database.

      csql> show tables;
        Tables_in_demodb
      ======================
      'athlete'
      'code'
      'event'
      'game'
      'history'
      'nation'
      'olympic'
      'participant'
      'record'
      'stadium' 

      Run the following sql to see the results.

      csql>
      SELECT s.nation_code, s.name, s.seats
      FROM stadium s
      ORDER by s.seats desc
      LIMIT 10 offset 0;
        nation_code           name                        seats
      =========================================================
      'AUS'                 'Olympic Stadium'          115600
      'KOR'                 'Seoul Olympic Stadium'       100000
      'AUS'                 'Melbourne Cricket Ground, Melbourne'        98000
      'USA'                 'Sanford Stadium'           86100
      'USA'                 'Olympic Stadium'           85600
      'USA'                 'Legion Field'              81700
      'AUS'                 'Sydney International Regatta Centre, Penrith Lakes'        73000
      'USA'                 'Orange Bowl'               72700
      'GRE'                 'Athens Olympic Stadium '        71030
      'USA'                 'Florida Citrus Bowl'        65000
              				
    • JDBC Programming

      The following example shows how to execute the SELECT statement by connecting to demodb which is automatically created when installing CUBRID.

      GettingStartedExample.java
      import java.sql.Connection;
      import java.sql.DriverManager;
      import java.sql.PreparedStatement;
      import java.sql.ResultSet;
      import java.sql.SQLException;
      public class GettingStartedExample {
          public static void main(String[] args) {
              Connection connection = null;
              PreparedStatement prepareStatement = null;
              ResultSet resultSet = null;
              try {
                  Class.forName("cubrid.jdbc.driver.CUBRIDDriver");
                  connection = DriverManager.getConnection("jdbc:cubrid:localhost:33000:demodb:::","dba","");
                  String sql = "SELECT p.host_year, p.nation_code, p.gold FROM participant p WHERE p.host_year = ? GROUP BY p.nation_code ORDER BY p.gold DESC LIMIT 10 OFFSET 0";
                  prepareStatement = connection.prepareStatement(sql);
                  prepareStatement.setString(1, "2004");
                  resultSet = prepareStatement.executeQuery();
                  while(resultSet.next()) {
                     int host_year = resultSet.getInt("host_year");
                     String nation_code = resultSet.getString("nation_code");
                     int gold = resultSet.getInt("gold");
                     System.out.println("host_year: " + host_year + ", nation_code: " + nation_code + ", gold: " + gold);
                  }
                  resultSet.close();
                  prepareStatement.close();
                  connection.close();
              } catch (ClassNotFoundException e) {
                  e.printStackTrace();
              } catch (SQLException e) {
                  e.printStackTrace();
              } finally {
                  if (resultSet != null) try { resultSet.close(); } catch(SQLException ex) {}
                  if (prepareStatement != null) try { prepareStatement.close(); } catch(SQLException ex) {}
                  if (connection != null) try { connection.close(); } catch(SQLException ex) {}
              }
          }
      }
                      	    

      After compiling, running the example shows the result of executing the SELECT statement.

      > javac GettingStartedExample.java
      > java -cp $CLASSPATH:.:$CUBRID/jdbc/cubrid_jdbc.jar GettingStartedExample
      host_year: 2004, nation_code: USA, gold: 36
      host_year: 2004, nation_code: CHN, gold: 32
      host_year: 2004, nation_code: RUS, gold: 27
      host_year: 2004, nation_code: AUS, gold: 17
      host_year: 2004, nation_code: JPN, gold: 16
      host_year: 2004, nation_code: GER, gold: 13
      host_year: 2004, nation_code: FRA, gold: 11
      host_year: 2004, nation_code: ITA, gold: 10
      host_year: 2004, nation_code: CUB, gold: 9
      host_year: 2004, nation_code: GBR, gold: 9
    • Installing and Running CUBRID
    • Creating Database
    • Running SQL with CSQL
    • JDBC Programming
    • Installing and Running CUBRID (Windows)

      CUBRID supports only 64-bit Windows. You can check the version by selecting [My Computer] > [System Properties]. Make sure to install a CUBRID 64-bit version on 64-bit Windows.

      Installation Process (Launch .msi or .exe)
      Step 1: Specifying the directory to install

      Step 2: Creating a sample database

      - To Create a sample database, Around 1.5GB disk space is required

      Step 3: Completing the installation

      - CUBRID Service Tray appears on the right bottom.


      - CUBRID Service automatically started when the system reboots. If you want to stop the when the system reboots, change the "Start parameters" of "CUBRIDService" as "Stop"; [Control Panel] > Administrative Tools > Services" and double-click "CUBRIDService", then the pop-up window will be shown.
      Checklist After Installation

      - Whether CUBRID Service Tray starts automatically
      If CUBRID Service Tray does not automatically start when starting a system, confirm the following.

      - Check if Task Scheduler is started in [Start button] > [Control panel] > [Administrative Tools] > [Services]; if not, start Task Scheduler.
      - Check if Cubrid Service Tray is registered in [Start button] > [All Programs] > [Startup]; if not, register CUBRID Service Tray.

      After CUBRID is installed, you can check the installed CUBRID version as follows.

      - In the system tray, right-click the CUBRID Service Tray. To Check CUBRID version, select [About].


      Running CUBRID
      Run Cmd(Command Prompt) as administrator

      - An administrator level (SYSTEM) authorization is required to start/stop CUBRID processes through the CUBRID Service tray; a login level user authorization is required to start/stop them with shell commands. If you cannot control the CUBRID processes on the Windows environment, select [Execute as an administrator (A)] in the [Start] > [All Programs] > [Accessories] > [Command Prompt]) or execute it by using the CUBRID Service Tray. When all processes of CUBRID Server stop, an icon on the CUBRID Service tray turns into grey.


      Shell Command

      You can start CUBRID master, CUBRID broker and CUBRID Manager server as follows.

      > cubrid service start
      @ cubrid master start
      ++ cubrid master start: success
      @ cubrid broker start
      ++ cubrid broker start: success
      @ cubrid manager server start
      ++ cubrid manager server start: success

      The database server does not start automatically by default.
      You can start demodb, which is created by default as follows.

      > cubrid server start demodb
      @ cubrid server start: demodb
      This may take a long time depending on the amount of recovery works to do.
      CUBRID major_version.minor_version
      ++ cubrid server start: success

      The following example shows how to check the status of master process and database server registered.

      > cubrid service status
      @ cubrid master status
      ++ cubrid master is running.
      @ cubrid server status
       Server demodb (rel major_version.minor_version, pid 9738)
      @ cubrid broker status
        NAME                   PID  PORT    AS   JQ                  TPS                  QPS   SELECT   INSERT   UPDATE   DELETE   OTHERS     LONG-T     LONG-Q         ERR-Q  UNIQUE-ERR-Q  #CONNECT   #REJECT
      ===========================================================================================================================================================================================================
      * query_editor          9672 30000     5    0                    0                    0        0        0        0        0        0     0/60.0     0/60.0             0             0         0         0
      * broker1               9683 33000     5    0                    0                    0        0        0        0        0        0     0/60.0     0/60.0             0             0         0         0
      @ cubrid manager server status
      ++ cubrid manager server is running.
                      		  
      CUBRIDService or CUBRID Service Tray

      In the Windows enviroment, you can start or stop a service as follows:

      - Go to [Control Panel] > [Administrative Tools] > [Services] and select the CUBRIDService to start or stop the service.

      - In the system tray, right-click the CUBRID Service Tray. To start CUBRID, select [Service Start]; to stop it, select [Service Stop].

      Selecting [Service Start] or [Service Stop] menu would be like executing cubrid service start or cubrid service stop in a commamd prompt; this command runs or stops the processes configured in service parameters of cubrid.conf.
      - If you click [Exit] while CUBRID is running, all the services and process in the server stop.

    • Creating Database

      The following example shows how to create a new database.

      > mkdir %CUBRID_DATABASES%\testdb
      > cubrid createdb -F %CUBRID_DATABASES%\testdb -v testdb en_US
      Creating database with 512.0M size using locale en_US. The total amount of disk space needed is 1.5G.
      CUBRID 10.2
                      

      When creating a new database, the following files are created by default.

      > dir %CUBRID_DATABASES%\testdb
      04/13/0000  02:59 PM    <DIR>          .
      04/13/0000  02:59 PM    <DIR>          ..
      04/13/0000  02:59 PM               326 csql.err
      04/13/0000  02:48 PM    <DIR>          lob
      04/13/0000  02:48 PM       536,870,912 testdb
      04/13/0000  02:48 PM       536,870,912 testdb_lgar_t
      04/13/0000  02:48 PM       536,870,912 testdb_lgat
      04/13/0000  02:48 PM               192 testdb_lginf
      04/13/0000  02:48 PM               223 testdb_vinf
                     6 File(s)  1,610,613,477 bytes
                     3 Dir(s)  156,211,499,008 bytes free
    • Running SQL with CSQL

      The CSQL Interpreter is an application that is installed with CUBRID.
      It can directly connect to the CUBRID database and perform various operations using SQL statements.

      You can connect directly to the CUBRID database with the CSQL Interpreter as follows.

      > csql -u dba demodb
          CUBRID SQL Interpreter
      Type `;help' for help messages.
      csql> 

      The following SQL shows a list of all databases that exist in the directory file ($CUBRID_DATABASES/databases.txt).

      csql> SELECT list_dbs();
         list_dbs()
      ======================
      'testdb demodb'

      The following SQL shows the connected database name and user name.

      csql> SELECT database(), CURRENT_USER;
         database()            CURRENT_USER
      ============================================
      'demodb'              'DBA'

      The following SQL shows the list of all table names in the database.

      csql> show tables;
        Tables_in_demodb
      ======================
      'athlete'
      'code'
      'event'
      'game'
      'history'
      'nation'
      'olympic'
      'participant'
      'record'
      'stadium' 

      Run the following sql to see the results.

      csql>
      SELECT s.nation_code, s.name, s.seats
      FROM stadium s
      ORDER by s.seats desc
      LIMIT 10 offset 0;
        nation_code           name                        seats
      =========================================================
      'AUS'                 'Olympic Stadium'          115600
      'KOR'                 'Seoul Olympic Stadium'       100000
      'AUS'                 'Melbourne Cricket Ground, Melbourne'        98000
      'USA'                 'Sanford Stadium'           86100
      'USA'                 'Olympic Stadium'           85600
      'USA'                 'Legion Field'              81700
      'AUS'                 'Sydney International Regatta Centre, Penrith Lakes'        73000
      'USA'                 'Orange Bowl'               72700
      'GRE'                 'Athens Olympic Stadium '        71030
      'USA'                 'Florida Citrus Bowl'        65000
              				
    • JDBC Programming

      The following example shows how to execute the SELECT statement by connecting to demodb which is automatically created when installing CUBRID.

      GettingStartedExample.java
      import java.sql.Connection;
      import java.sql.DriverManager;
      import java.sql.PreparedStatement;
      import java.sql.ResultSet;
      import java.sql.SQLException;
      public class GettingStartedExample {
          public static void main(String[] args) {
              Connection connection = null;
              PreparedStatement prepareStatement = null;
              ResultSet resultSet = null;
              try {
                  Class.forName("cubrid.jdbc.driver.CUBRIDDriver");
                  connection = DriverManager.getConnection("jdbc:cubrid:localhost:33000:demodb:::","dba","");
                  String sql = "SELECT p.host_year, p.nation_code, p.gold FROM participant p WHERE p.host_year = ? GROUP BY p.nation_code ORDER BY p.gold DESC LIMIT 10 OFFSET 0";
                  prepareStatement = connection.prepareStatement(sql);
                  prepareStatement.setString(1, "2004");
                  resultSet = prepareStatement.executeQuery();
                  while(resultSet.next()) {
                     int host_year = resultSet.getInt("host_year");
                     String nation_code = resultSet.getString("nation_code");
                     int gold = resultSet.getInt("gold");
                     System.out.println("host_year: " + host_year + ", nation_code: " + nation_code + ", gold: " + gold);
                  }
                  resultSet.close();
                  prepareStatement.close();
                  connection.close();
              } catch (ClassNotFoundException e) {
                  e.printStackTrace();
              } catch (SQLException e) {
                  e.printStackTrace();
              } finally {
                  if (resultSet != null) try { resultSet.close(); } catch(SQLException ex) {}
                  if (prepareStatement != null) try { prepareStatement.close(); } catch(SQLException ex) {}
                  if (connection != null) try { connection.close(); } catch(SQLException ex) {}
              }
          }
      }
                      	    

      After compiling, running the example shows the result of executing the SELECT statement.

      > javac GettingStartedExample.java
      > java -cp %CLASSPATH%:.:%CUBRID%\jdbc\cubrid_jdbc.jar GettingStartedExample
      host_year: 2004, nation_code: USA, gold: 36
      host_year: 2004, nation_code: CHN, gold: 32
      host_year: 2004, nation_code: RUS, gold: 27
      host_year: 2004, nation_code: AUS, gold: 17
      host_year: 2004, nation_code: JPN, gold: 16
      host_year: 2004, nation_code: GER, gold: 13
      host_year: 2004, nation_code: FRA, gold: 11
      host_year: 2004, nation_code: ITA, gold: 10
      host_year: 2004, nation_code: CUB, gold: 9
      host_year: 2004, nation_code: GBR, gold: 9

Join the CUBRID Project on