db2tablespace

How to create tablespace in DB2?


I want to create tablespace in DB2 and my platform is AIX.

I want to have that tablespace in a directory at my operating system. I have also created a bufferpool having the same pagesize of tablespace. But getting SQLCODE=-104.

CREATE BUFFERPOOL BPOOL  SIZE 2000 PAGESIZE 16K;

CREATE TABLESPACE TS01 

MANAGED BY DATABASE 
USING ( '/dbdata/UMPSYS01' )  
PAGESIZE 16K
BUFFERPOOL BPOOL 

I have tried with DEVICE and FILE tokens giving the sizes too. But unable to run it.

Following error I am getting:

18:13:38  [CREATE - 0 row(s), 0.000 secs]  [Error Code: -104, SQL State: 42601]  DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=USING ( '/dbdata/UMPSYS01' );ESPACE TS01 
;<space>, DRIVER=3.61.75

Solution

  • It's very important (unforunately) that you get the syntax correct, with the keys in the right order. The syntax diagram for the CREATE TABLESPACE statement is available here.

    You've put the PAGESIZE clause after the MANAGED BY ... which is incorrect. It should be before:

    CREATE TABLESPACE TS01 
        PAGESIZE 16K
        MANAGED BY DATABASE 
        USING (FILE '/dbdata/UMPSYS01.dms' 100M)  
        BUFFERPOOL BPOOL