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 :
[--db-volume-size=size] [--db-page-size=size] [--log-volume-size=size] [--log-page-size=size] [--comment=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]
The following table shows options that can be used with cubrid createdb. Options are case sensitive.
|
Option |
Description |
|---|---|
|
--db-volume-size |
Specifies the size of the database volume that will be created first in bytes. |
|
--db-page-size |
Specifies the database page size in bytes. |
|
--log-volume-size |
Specifies the log volume size in bytes. |
|
--log-page-size |
Specifies the page size of log volume in bytes. |
|
--comment |
Adds information on the database to be created in the form of a comment. |
|
-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 |
|
--server-name |
Specifies the name of the server host to connect to. |
|
-r |
Allows overwriting if the name of the database to be created is the same as that of an existing database. |
|
--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. |
|
-o |
Specifies the file where output messages concerning database creation are stored. |
|
-v |
Displays detailed messages to the screen concerning database creation. |
Size of the first database volume (--db-volume-size)
The --db-volume-size option is used to specify the size of the database volume that will be created first. The default value is the value of the system parameter db_volume_size, and the minimum value is 20M. You can set units as K, M, G and T, which stand for KB(kilobytes), MB(megabytes), GB(gigabytes) and TB(terabytes), respectively. If you omit the unit, bytes will be applied.
The following example shows creating a database named testdb and assigning 256MB to its first volume.
cubrid createdb --db-volume-size=512M testdb
Database page size (--db-page-size)
The --db-page-size option is used to specify the size of the database page to be one of 4K(4KB), 8K(8KB), and 16K(16KB). The default vaule is 16K. If any number besides these is specified, the system rounds up the number. If a number which is greater than 16K, 16K is used.
The following example shows creating a database named testdb and setting its page size 16KB.
cubrid createdb --db-page-size=16K testdb
Log volume size (--log-volume-size)
The --log-volume-size option is used to specify the size of the database log volume. The default value is the databse volume size, and the minimum value is 20M. You can set units as K, M, G and T, which stand for KB(kilobytes),MB (megabytes), GB(gigabytes) and TB(terabytes), respectively. If you omit the unit, bytes will be applied.
The following example shows creating a database named testdb and assigning 256MB to its log volume.
cubrid createdb --log-volume-size=256M testdb
Log page size (--log-page-size)
The --log-page-size option specifies the size of the log volume page to be one of 4K(4KB), 8K(8KB), and 16K(16KB). The default value is the size of the data page. If any number besides these is specified, the system rounds up the number. If a number which is greater than 16K, 16K is used.
The following example shows creating a database named testdb and setting its log volume page size 8KB.
cubrid createdb --log-page-size=8K testdb
Comment (--comment)
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.
The following example shows creating a database named testdb and adding a related comment to the database volume.
cubrid createdb --comment "a new database for study" testdb
Database directory path (-F)
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.
The following example shows creating a database named testdb in the directory /dbtemp/new_db.
cubrid createdb -F "/dbtemp/new_db/" testdb
Log file directory path (-L)
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.
The following example shows creating a database named testdb in the directory /dbtemp/newdb and log files in the directory /dbtemp/db_log.
cubrid createdb -F "/dbtemp/new_db/" -L "/dbtemp/db_log/" testdb
LOB data file directory (--lob-base-path)
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.
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.
cubrid createdb --lob-base-path "file:/home1/data1" testdb
Server host name (--server-name)
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 on 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.
The following example shows creating and registering a database named testdb on the aa_host host.
cubrid createdb --server-name aa_host testdb
Overwrite (-r)
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.
The following example shows creating a new testdb database which overwrites the existing database with the same name.
cubrid createdb -r testdb
Adding a database volume (--more-volume-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.
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.
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
User information file (--user-definition-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.
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.
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
File containing CSQL statements (--csql-initialization-file)
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.
The following example shows creating a database named testdb and executing the SQL statement defined in table_schema.sql through the CSQL Interpreter.
cubrid createdb --csql-initialization-file table_schema.sql testdb
Saving output messages to a file (-o)
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 on the creation of a certain database by saving messages, generated during the database creation, to a specified file.
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.
cubrid createdb -o db_output testdb
Verbose output (-v)
The -v option is used to output all information on 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.
The following example shows creating a database named testdb and outputting detailed information on the operation onto the screen.
cubrid createdb -v testdb