Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

How to Create a CUBRID Database


In this tutorial you will learn how to quickly create a database in CUBRID. If you use a Desktop version of the OS and prefer using GUI tools instead of a terminal, you may perform all of the commands below in CUBRID Manager.

To start with let's create a sample database. Type the following command in the terminal. This assumes that CUBRID is installed in your system (or see installation instructions). If necessary, replace sample_db with your own database name.

cubrid createdb sample_db

This will create a database in your current working directory with a user dba and a blank password. If necessary, you can set a user password at this step or change it later.

If you want to keep your databases in a certain directory, first navigate to that directory and then execute the above createdb command in that directory.

Once you have created a database, you need to start it before you try to connect to it.

cubrid server start sample_db

If you decided to use a command line terminal, you need to connect to a database to execute SQL queries. CUBRID provides CSQL command line SQL interpreter for this. Let's connect to a database.

csql sample_db -u dba

CSQL Interpreter

Type `;help' for help messages.

csql>

Now create a table to hold users' data. SQL in CUBRID is very much same to that of MySQL.

CREATE TABLE "tbl_users"(
    "id" integer AUTO_INCREMENT,
    "email" varchar(100) NOT NULL UNIQUE,
    "join_date" integer NOT NULL,
    CONSTRAINT pk_tbl_users_id PRIMARY KEY("id")
);

Copy and paste the above schema declaration in the CSQL and press Enter.

Now let's insert some data into the table using CSQL.

INSERT INTO tbl_users (email, join_date) VALUES
('7hyn6@peg30xmw1hcdrcg.gov', 1328523265),
('29ggzm3@cexbebaju9pkrq.net', 1328534265),
('4yn69iqqe@rh6c5b28xaw.gov', 1328528265),
('dyku2b8@wzfofw5aqymu7.biz', 1323423265),
('7au9hv1u@boi1ba1wowlfj3m.org', 1328523665);

At this point you have learnt how to create a database and a table as well as insert sample data.

Can't start your database?

There can be several reasons why your database may fail to start.

  1. Make sure your hostname resolves (by editing hosts file) to the IP of your server (eg. localhost or 127.0.0.1). It is common that users forget to ensure this. Note that CUBRID doesn't support IPv6, which means your hostname should resolve to an IPv4 address.
  2. Make sure your server has enough memory. By default CUBRID Server is configured (via data_buffer_size server parameter) to demand 512MB of memory to start a single database. Your options are either to increase your memory to satisfy the minimum requirements, or decrease the data_buffer_size parameter value.
comments powered by Disqus
Page info
viewed 9796 times
translations en
Author
posted 2 years ago by
CUBRID
Contributors
updated last year by
View revisions
Share this article