Summary: Learn how to create a dedicated business dbspace in GBase Database(GBase 8s), configure a 16KB page size, create a database inside that space, explicitly place tables, and verify storage allocation with onstat -d. This step-by-step guide also covers chunk file permissions, default storage placement, and BLOB/CLOB storage considerations.
1. Understand the Storage Structure Before Starting
A dbspace in GBase Database(GBase 8s) is a logical storage container backed by one or more chunk files.
In this tutorial, we will build a complete storage workflow:
- Prepare a chunk file.
- Create a business dbspace.
- Verify the dbspace.
- Create a database inside that dbspace.
- Create tables and control their storage placement.
- Verify the actual storage allocation.
The goal is to create a business dbspace named datadbs01 with a 16KB page size and ensure that the new database and its tables use the intended storage space instead of relying on rootdbs.
2. Step 1: Prepare the Chunk File and Permissions
The onspaces utility does not create the operating system file for you. The chunk file must exist before creating the dbspace.
First, create the directory and an empty file:
mkdir -p /data/gbase
touch /data/gbase/datachk01
chown gbasedbt:gbasedbt /data/gbase/datachk01
chmod 660 /data/gbase/datachk01
These commands perform three essential operations:
-
touch: Create an empty chunk file. -
chown: Assign ownership togbasedbt:gbasedbt. -
chmod 660: Grant read and write permissions to the owner and group.
Before continuing, verify the file:
ls -l /data/gbase/datachk01
Expected permissions:
-rw-rw---- gbasedbt gbasedbt
If the file is created as root but ownership is not corrected, dbspace creation may fail when GBase Database attempts to open the chunk file.
Checkpoint: Confirm that the file exists and has the correct owner and permissions before running onspaces.
3. Step 2: Create a 16KB Business Dbspace
Now create the dbspace:
onspaces -c -d datadbs01 \
-p /data/gbase/datachk01 \
-o 0 -s 102400 -k 16
Understand the parameters:
| Parameter | Meaning |
|---|---|
-c |
Create a dbspace |
-d |
Dbspace name |
-p |
Chunk file path |
-o |
Offset |
-s |
Chunk size in KB |
-k |
Page size in KB |
In this example:
- Dbspace:
datadbs01 - Chunk file:
/data/gbase/datachk01 - Offset:
0 - Chunk size:
102400KB - Page size:
16KB
The page size is a creation-time decision. It cannot be changed afterward.
Also, size the dbspace according to current data requirements and expected growth rather than simply allocating enough space for the initial tables.
4. Step 3: Verify the Dbspace
After creation, check the database storage configuration:
onstat -d | grep -i datadbs01
For a more complete inspection, run:
onstat -d
Pay attention to two sections:
Dbspaces
Check whether datadbs01 appears and confirm its page size and chunk count.
Chunks
Check the physical file path, chunk size, free pages, and status flags.
A nchunks value of 1 indicates that the dbspace currently contains one chunk. Additional chunks can be added as storage requirements grow.
Checkpoint: Do not proceed until the dbspace and its chunk are correctly reported.
5. Step 4: Create the Database in the Business Dbspace
Now create the database:
CREATE DATABASE mesdb IN datadbs01 WITH LOG;
The IN datadbs01 clause specifies the dbspace in which the database is created.
This is important because it establishes the default storage location for database objects that do not explicitly specify another dbspace.
Without an explicit storage plan, business objects may end up in rootdbs, making future capacity management more difficult.
6. Step 5: Create Tables and Control Their Placement
Once the database exists, create business tables.
For example:
CREATE TABLE prod_order (
order_id SERIAL,
prod_code VARCHAR(32),
created_at DATETIME YEAR TO SECOND
) IN datadbs01;
You can also explicitly place another table in a different dbspace:
CREATE TABLE prod_order_hist (
order_id SERIAL,
prod_code VARCHAR(32),
created_at DATETIME YEAR TO SECOND
) IN datadbs02;
This illustrates a simple hot/cold storage separation strategy:
-
datadbs01: Current business data. -
datadbs02: Historical business data.
The key rule is that an explicit IN clause takes precedence over the database's default dbspace.
If the table creation statement does not specify IN, the database-level default determines its placement.
This is why storage planning must be included in both database creation scripts and application DDL templates.
7. Step 6: Verify Actual Storage Placement
A successful CREATE TABLE statement does not necessarily mean the intended storage layout has been implemented correctly.
Run:
onstat -d
Check the free pages in the target dbspaces.
After inserting data, you can compare the free space before and after the operation to observe storage consumption.
For more detailed verification, GBase Database's sysmaster database provides system catalog information through tables such as:
sysdbspacessyschunks
These can help inspect dbspace and chunk metadata.
One important distinction: onstat -d verifies space-level allocation, not the exact table-to-dbspace mapping. For object-level verification, use the appropriate catalog metadata for your GBase Database version.
The storage plan is only complete when the actual object placement matches the design.
8. Step 7: Automate the Creation Process
Once the manual procedure works, turn it into a reusable deployment script.
At minimum, the function should accept:
- Chunk file path
- Dbspace name
- Chunk size
- Page size
It should also verify:
- The target directory exists.
- The chunk file is created successfully.
- Ownership is
gbasedbt:gbasedbt. - Permissions are set correctly.
- The dbspace does not already exist.
- The
onspacescommand completes successfully.
This turns a sequence of manual operations into a repeatable deployment process.
In database administration, automation is not simply about executing commands faster. It is about ensuring that every deployment follows the same prerequisites and verification steps.
9. Important: BLOB and CLOB Need a Separate Storage Path
There is one more storage rule worth remembering.
If a table contains BLOB or CLOB columns, placing the table in an ordinary dbspace does not determine where its smart large objects are stored.
In GBase Database(GBase 8s), BLOB and CLOB are smart large objects and must use an sbspace.
For example:
CREATE TABLE prod_image (
id SERIAL,
img BLOB
) IN datadbs01
PUT img IN (sbspace01);
Here:
-
datadbs01stores the ordinary table data. -
sbspace01stores the BLOB data.
Table placement and smart large object placement are separate storage decisions.
Make sure the sbspace exists and is usable before creating tables that depend on it.
Conclusion: Storage Planning Is More Than Creating a Dbspace
Creating a business dbspace is only the first step in GBase Database storage management.
A complete deployment must connect four operations:
Create space → Create database → Place tables → Verify allocation
The most important principles are:
- Prepare chunk files with the correct ownership and permissions.
- Choose page size before dbspace creation.
- Create databases in the intended business dbspace.
- Use explicit
INclauses when table placement matters. - Verify actual allocation instead of relying only on successful SQL execution.
- Give BLOB/CLOB their own sbspace storage configuration.
GBase Database provides the commands and administration tools. A well-designed deployment process ensures those tools produce a predictable and maintainable storage architecture.
The difference between creating a database and building a reliable database environment is whether the storage plan is actually reflected in the objects running inside it.
Keywords: GBase Database, GBase Database 8s, dbspace creation, database storage management, onspaces, chunk file permissions, table placement, sbspace, database deployment
Top comments (0)