Open Source RDBMS - Seamless, Scalable, Stable and Free

English | 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.

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.

comments powered by Disqus
문서 정보
viewed 5414 times
번역 en
작성자
posted 작년
CUBRID
공헌자
마지막 수정시간 6달 전
변경 내역 보기
Share this article