1 Enabling a database for spatial operations
Before you enable a database for spatial operations:
- Ensure that your user ID have DBADM authority on the database.
- Ensure that you have a system temporary table space with a page size of 8 KB or larger and with a minimum size of 500 pages.
To create the system temporary tablespace, connect to database server executing the following as user db2
# su - db2 # db2 db2 => CREATE BUFFERPOOL tempbuff8k IMMEDIATE SIZE 5000 PAGESIZE 8K db2 => CREATE SYSTEM TEMPORARY TABLESPACE tempbuff8k PAGESIZE 8K BUFFERPOOL tempbuff8k
1.1 About this task
The task of having DB2® Spatial Extender supply a database with resources for creating spatial columns and manipulating spatial data is generally referred to as "enabling the database for spatial operations".
You can enable a database for spatial operations in any of the following ways:
- Use the Enable Database window from the DB2 Spatial Extender menu option. The menu option is available from the database object of the DB2 Control Center.
- Issue the db2se enable_db command.
- Run an application that calls the db2gse.ST_enable_db stored procedure.
You can explicitly choose the table space in which you want the DB2 Spatial Extender catalog to reside. If you do not do so, DB2 will use the default table space.
If you want to use spatial data in a partitioned environment, do not use the default table space. For best results, enable the database in a tablespace that is defined for a single nodes. Typically a single node tablespace is defined for small tables where partitioning is not helpful.
For example, you can define a single node tablespace using the db2se command line processor as user with privileges to execute this command db2inst1:
# su - db2inst1 # db2se enable_db my_db [-tableCreationParameters “IN NODE0TBS”]
In addition is possible that could be necessary to execute, connecto to the database as user db2
# su - db2 # db2 db2 => connect to mydb db2 => SET CURRENT FUNCTION PATH = CURRENT FUNCTION PATH, db2gse
to allow to create tables with geometric fields, as for example:
CREATE TABLE sample_geometries(id INTEGER, geometry ST_GEOMETRY)
2 Tablespace for temporary tables
To use temporary tables it is necessary create a tablespace for this kind of tables. First increase the size for the default bufferpool and then create a tablespace for each database.
$> db2 ... db2 => connect to mydb db2 => ALTER BUFFERPOOL IBMDEFAULTBP SIZE 5000
Tablespace file name
Use a different name for the file on each database.
$> db2 ... db2 => connect to mydb db2 => CREATE USER TEMPORARY TABLESPACE usr_tbsp MANAGED BY DATABASE USING (FILE '/home/db2/TEMPSPACE/mydb_tbsp' 5000)
Now you can try to create a temporary table as for example:
$> db2 ... db2 => connect to mydb db2 => CREATE GLOBAL TEMPORARY TABLE tempx (P_USER VARCHAR (20),P_CHAR_20 VARCHAR (20),P_INT INTEGER NOT NULL,P_CHAR_1200 VARCHAR (1200))
3 Enabling Text Search on Database
First of all you must install text search module before to use this feature. If you had alreadey installed it with the product this step it is not necessary.
Execute the command
from the command line to starts the wizard to install the module.
In order to enable Text Search feature the database must be created with codeset UTF-8.
# su - db2 # db2 db2 => CREATE DATABASE mytstest USING CODESET UTF-8 TERRITORY US