Db2 tablespace expansion is a common operation. The following describes how to expand tablespaces and field lengths in db2. If you have encountered this problem, take a look.
1. When we use db2 to import data or perform other operations, the transaction log is full, causing the operation to fail.
In windows, We can first view the data configuration by using db2 get db cfg for dbname (the name of the database to be modified.
Modify the size of the log file, the number of master log files, and the number of auxiliary log files as needed. The command is as follows:
1. db2 "update db cfg for dbname using logfilsiz XXX (4-262144 )".
2. db2 "update db cfg for dbname using logprimary X (2-256 )".
3. db2 "update db cfg for dbname using logsecond XX (0-254 )".
When performing these operations, you must disconnect the connection between the application and the database.
2. How to expand the tablespace of data.
First, you can use db2 list tablespaces show detail to view your tablespace status.
There are two types of tablespaces:
1. SMSSYSCATSPACE: the system management tablespace.
2. DMS: the user's own tablespace, which is used to manage the tablespace for the database.
Use the preceding command to view the Total and Free pages of tablespaces. If the system manages insufficient tablespaces (SMS), the disk space is insufficient, you need to increase disk space. If the database management tablespace (DMS) is insufficient, you need to expand the tablespace. The command to expand the tablespace is:
Db2 alter tablespace extend (all <num_pages>)
Example: db2 alter tabblespace yourtablespace extend (all 1024 M)
Extended database tablespace 1 GB.
3. Expand the length of fields in the table.
Due to data changes, the original varchar (2000) field length is not enough. In fact, it is very easy to help:
Db2. "alter table tabname alter column colname set data type varchar (4000 )"
Modify the colname field of the tabname table to set its length to 4000.
The data type after data type must be consistent with the colname type in tabname.
DB2 strings in DB2 Databases
Analyze the advantages of the DB2 database
Four precautions for DB2 Data Import
DB2 Management page size limit
Policy Selection for DB2 environment variable Management