Versions available for this page: CUBRID 8.3.1 | CUBRID 8.4.0 | CUBRID 8.4.1 |
The cubrid createdb utility creates databases and initializes them with the built-in CUBRID system tables. It can also define initial users to be authorized in the database and specify the locations of the logs and databases. Generally, the cubrid createdb utility is used only by DBA.
cubrid createdb options database_name
options :
[{-p|--pages=}number]
[--comment]
[{-F|--file-path=}path]
[{-L|--log-path=}path]
[{-B|--lob-base-path=}path]
[--server-name=host ]
[{-r | --replace} ]
[--more-volume-file=file]
[--user-definition-file=file]
[ --csql-initialization-file=file]
[{-o|--output-file=} file]
[{-v | --verbose}]
[{-l | --log-page-count=} number]
[--log-page-size=size]
[ {-s | --page-size=} size]
The following table shows options that can be used with cubrid createdb. Options are case sensitive.
|
Option |
Description |
|---|---|
|
-p |
Specifies the number of pages of the database volume (generic) to be created. |
|
-F |
Specifies the directory path where the database will be created. |
|
-L |
Specifies the directory path where log files will be stored. |
| -B --lob-base-path |
Specifies the directory path where LOB data files will be stored. Default value : <location of database volumns created>/lob directory |
|
-r |
Allows overwriting if the name of the database to be created is the same as that of an existing database. |
|
-o |
Specifies the file where output messages concerning database creation are stored. |
|
-v |
Displays detailed messages to the screen concerning database creation. |
|
-l |
Specifies the number of pages of the log volume. |
|
--log-page-size |
Specifies the page size of log volume in unit of byte. |
|
-s |
Specifies the database page size in bytes. |
|
--comment |
Adds information about the database to be created in the form of a comment. |
|
--server-name |
Specifies the name of the server host to connect to. |
|
--more-volume-file |
Specifies the file that includes the specifications for creating an additional volume of the database. |
|
--user-definition-file |
Specifies the file that includes user definitions. |
|
--csql-initialization-file |
Specifies the file for csql initialization. |
Number of pages (-p)
The following example shows creating a database named testdb to which 10,000 pages are assigned. The -p option is used to specify the number of pages for a database application. The default value is 5,000.
cubrid createdb -p 10000 testdb
Database directory path (-F)
The following example shows creating a database named testdb in the directory /dbtemp/new_db.
The -F option is used to specify the absolute path to a directory where the new database will be created. If the -F option is not specified, the new database is created in the current working directory.
cubrid createdb -F "/dbtemp/new_db/" testdb
Log file directory path (-L)
The following example shows creating a database named testdb in the directory /dbtemp/newdb and log files in the directory /dbtemp/db_log.
The -L option is used to specify the absolute path to the directory where database log files are created. If the -L option is not specified, log files are created in the directory specified by the -F option. If neither -F nor -L option is specified, database log files are created in the current working directory.
cubrid createdb -F "/dbtemp/new_db/" -L "/dbtemp/db_log/" testdb
LOB data file directory (--lob-base-path)
The following example shows creating a database called testdb in the working directory and specifying "/home/data1" of local file system as a location of LOB data files.
The --lob-base-path option is used to specify a directory where LOB data files are stored when BLOB/CLOB data is used. If the --lob-base-path option is not specified, LOB data files are store in "<location of database volumns created>/lob" directory.
cubrid createdb --lob-base-path "file:/home1/data1" testdb
Overwrite (-r)
The following example shows creating a new testdb database which overwrites the existing database with the same name.
The -r option is used to create a new database and overwrite an existing database if one with the same name exists. If the -r option is not specified, database creation is halted when this occurs.
cubrid createdb -r testdb
Saving output messages to a file (-o)
The following example shows creating a database named testdb and saving the output of the utility to the db_output file instead of displaying it on the console screen.
The -o option is used to save messages related to the database creation to the file given as a parameter. The file is created in the same directory where the database was created. If the -o option is not specified, messages are displayed on the console screen. The -o option allows you to use information about the creation of a certain database by saving messages, generated during the database creation, to a specified file.
cubrid createdb -o db_output testdb
Verbose output (-v)
The following example shows creating a database named testdb and outputting detailed information about the operation onto the screen.
The -v option is used to output all information about the database creation operation onto the screen. Like the -o option, this option is useful in checking information related to the creation of a specific database. Therefore, if you specify the -v option together with the -o option, you can save the output messages in the file given as a parameter; the messages contain the operation information about the cubrid createdb utility and database creation process.
cubrid createdb -v testdb
Log page (-l)
The following example shows creating a database named testdb and setting the number of pages of the log volume to 1,000.
The -l option is used to specify the number of pages of the database log volume. The default value is the number of pages of the generic volume specified by the -p option. The number of pages of the log volume varies depending on the data modification throughput and transaction duration, but an appropriate value is at least equal to or twice greater than that of the database volume.
cubrid createdb -l 1000 testdb
Log page size (--log-page-size)
This statement creates a database named testdb and sets the size of the log volume page to 4 Kbytes.
The --log-page-size option specifies the size of the log volume page of the created database. Its default value is the same as the page size of the generic volume specified by the -pages option. The log page size should be specified by considering the transaction interval, log capacity and I/O page size of the OS. If this value is set too high in an environment in which the log capacity is flushed to a disk due to a short transaction commit interval, a disk I/O cost may unnecessarily increase.
cubrid createdb
-?log-page-size 8192 testdb
Data page size (-s)
The following example shows setting the page size of the volume of the database named testdb to 8192 bytes.
The -s option is used to specify the size of the database page to be one of 1024, 2048, 4096, 8192 and 16384 bytes. The default value is 4096. If any number besides these is specified, the system configures the page size as the number of ceils. Note that if you change the page size of a database volume by using the -s option, related database parameters such as data_buffer_pages, sort_buffer_pages and log_buffer_pages are also affected.
cubrid createdb -s 8192 testdb
Comment (--comment)
The following example shows creating a database named testdb and adding a related comment to the database volume.
The --comment option is used to specify a comment to be included in the database volume header. If the character string contains spaces, the comment must be enclosed in double quotes.
cubrid createdb --comment "a new database for study" testdb
Server host name (--server-name)
The following example shows creating and registering a database named testdb on the aa_host host.
The --server-name option is used to specify that the server for a certain database will be running on a specified host when a client / server version of CUBRID is used. The information about the server host specified with this option is written in the database location file (databases.txt). If this option is not specified, the default value is the current localhost.
cubrid createdb --server-name aa_host testdb
Adding a database volume (--more-volume-file)
The following example shows creating a database named testdb as well as an additional volume based on the specification stored in the vol_info.txt file.
The --more-volume-file option creates an additional volume based on the specification contained in the file specified by the option. The volume is created in the same directory where the database is created. Instead of using this option, you can add a volume by using the cubrid addvoldb utility.
cubrid createdb --more-volume-file vol_info.txt testdb
The following is a specification of the additional volume contained in the vol_info.txt file. The specification of each volume must be written on a single line.
#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# NAME volname COMMENTS volcmnts PURPOSE volpurp NPAGES volnpgs
NAME data_v1 COMMENTS "Data information volume" PURPOSE data NPAGES 1000
NAME data_v2 COMMENTS "Data information volume" PURPOSE data NPAGES 1000
NAME data_v3 PURPOSE data NPAGES 1000
NAME index_v1 COMMENTS "Index information volume" PURPOSE index NPAGES 500
NAME temp_v1 COMMENTS "Temporary information volume" PURPOSE temp NPAGES 500
NAME generic_v1 COMMENTS "Generic information volume" PURPOSE generic NPAGES 500
#xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
As shown in the example, the specification of each volume is composed of followings.
NAME volname COMMENTS volcmnts PURPOSE volpurp NPAGES volnpgs
File containing CSQL statements (--csql-initialization-file)
The following example shows creating a database named testdb and executing the SQL statement defined in table_schema.sql through the CSQL Interpreter.
The --csql-initialization-file option executes an SQL statement on the database to be created by using the CSQL Interpreter. A schema can be created based on the SQL statement contained in the file specified by the parameter.
cubrid createdb --csql-initialization-file table_schema.sql testdb
User information file (--user-definition-file)
The following example shows creating a database named testdb and adding users to testdb based on the user information defined in the user_info.txt file.
The --user-definition-file option is used to add users who have access to the database to be created. It adds a user based on the specification contained in the user information file specified by the parameter. Instead of using the --user-definition-file option, you can add a user by using the Managing USER statement.
cubrid createdb --user-definition-file user_info.txt testdb
The syntax of a user information file is as follows:
USER user_name [ groups_clause | members_clause ]|
groups_clause:
[ GROUPS group_name [ { group_name }... ] ]
members_clause:
[ MEMBERS member_name [ { member_name... } ] ]
Comments can be used in a user information file. A comment line must begin with a hyphen (-). Blank lines are ignored.
The following example is a user information file that defines the group sedan to include grandeur and sonata, the group suv to include tuscan, and the group hatchback to include i30. The name of the user information file is user_info.txt.
--
-- Example 1 of a user information file
--
USER sedan
USER suv
USER hatchback
USER grandeur GROUPS sedan
USER sonata GROUPS sedan
USER tuscan GROUPS suv
USER i30 GROUPS hatchback
The following file defines the same user relationship as the one above, except that it uses the MEMBERS clause.
--
-- Example 2 of a user information file
--
USER grandeur
USER sonata
USER tuscan
USER i30
USER sedan MEMBERS sonata grandeur
USER suv MEMBERS tuscan
USER hatchback MEMBERS i30