db2tablespacedb2-zos

DB2 Z/OS - Rename Tablespace


I use DB2 Z/OS 11.01. It's possible to rename a tablespace already defined on DB2 z/OS? From the documentation I don't see any constraints but I can't.

Below I show you my test case:

  1. I create a TS, a table and an index.
--
  CREATE TABLESPACE TSFOOT
    IN DBTEST01
    USING STOGROUP SGTEST01
    PRIQTY 48 SECQTY 48
    ERASE  NO
    FREEPAGE 0 PCTFREE 5
    GBPCACHE CHANGED
    TRACKMOD YES
    MAXPARTITIONS 1
    LOGGED
    DSSIZE 4 G
    SEGSIZE 32
    BUFFERPOOL BP1
    LOCKSIZE ANY
    LOCKMAX SYSTEM
    CLOSE YES
    COMPRESS NO
    CCSID      EBCDIC
    DEFINE YES
    MAXROWS 255;
--  
  COMMIT;
--
  CREATE TABLE TEST01.TBFOOT
     (FIELD1   CHAR(2) FOR SBCS DATA NOT NULL,
      FIELD2   DATE NOT NULL,
      FIELD3   DECIMAL(7, 0) NOT NULL,
      FIELD4   DECIMAL(7, 0) NOT NULL,
      FIELD5   DECIMAL(3, 0) NOT NULL,
      CONSTRAINT PK_TBFOOT
      PRIMARY KEY (FIELD1,
                   FIELD2))
    IN DBTEST01.TSFOOT
    PARTITION BY SIZE
    AUDIT NONE
    DATA CAPTURE NONE
    CCSID      EBCDIC
    NOT VOLATILE
    APPEND NO  ;
--
  COMMIT;
--
  CREATE UNIQUE INDEX TEST01.IXFOOTP
    ON TEST01.TBFOOT
     (FIELD1    ASC,
      FIELD2    ASC)
    USING STOGROUP SGTEST01
    PRIQTY 48 SECQTY 48
    ERASE  NO
    FREEPAGE 0 PCTFREE 10
    GBPCACHE CHANGED
    CLUSTER
    COMPRESS NO
    INCLUDE NULL KEYS
    BUFFERPOOL BP2
    CLOSE NO
    COPY NO
    DEFER NO
    DEFINE YES
    PIECESIZE 2 G;
--
  COMMIT;
--
  CREATE SYNONYM TBFOOT FOR TEST01.TBFOOT;
--
  COMMIT;
-- 
  1. I run the statements to rename the tablespace.

RENAME TABLESPACE TSFOOT TO TSFOOT_NEW;

  1. I get the following error:

ILLEGAL SYMBOL "TSFOOT". SOME SYMBOLS THAT MIGHT BE LEGAL ARE: . TO. SQLCODE=-104, SQLSTATE=42601, DRIVER=4.19.56

Can I get some help here, please? Thank you very much.


Solution

  • Using Db2 you have to be cautious when looking for the documentation. There are 2 different platforms:

    Basically they have the same syntax. But there are slightly differences when digging deeper. Rule of thumb: z/OS supports less commands than Unix/Windows.

    In your case look at the correct documentation (and create a bookmark): https://www.ibm.com/support/knowledgecenter/SSEPEK_11.0.0/sqlref/src/tpc/db2z_sql_rename.html

    And you see that renaming table spaces on z/OS is not possible.