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
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 ('email@example.com', 1328523265), ('firstname.lastname@example.org', 1328534265), ('email@example.com', 1328528265), ('firstname.lastname@example.org', 1323423265), ('email@example.com', 1328523665);
At this point you have learnt how to create a database and a table as well as insert sample data.