0001039544

14
8/10/2019 0001039544 http://slidepdf.com/reader/full/0001039544 1/14 SAP Note Header Data Symptom You want to move tables online between tablespaces using the stored procedure ONLINE_TABLE_MOVE. Other Terms online table move stored procedure, OTM, DB2 LUW Reason and Prerequisites l If you are using DB2 V9.7 or higher, call the SYSPROC.ADMIN_MOVE_TABLE stored procedure. For more information, see the DB2 V9.7 documentation and SAP Note 1543745. l For Linux and UNIX only: You are using DB2 Version 8.2.2, DB2 Version 9.1 or DB2 Version 9.5. l For Windows only: You are using DB2 Version 9.1 or DB2 Version 9.5. l DB2 registry variable DB2_SKIPDELETED must be set to OFF. l The SYSTOOLSPACE tablespace must be accessible for 'PUBLIC'. To make it accessible, enter the following command: db2 "GRANT USE OF TABLESPACE SYSTOOLSPACE TO PUBLIC" l Read and understand the "Note" section below. Solution Related Concepts l Incremental Conversion (SAP transaction ICNV) --> See SAP Note 963602 l Moving Tables Using Report DB6CONV --> See SAP Note 362325 Note: l For DB2 Version 8.2.2, up to DB2 Version 9.1 Fix Pack 8 or up to DB2 Version 9.5 Fix Pack 5 (in the following Fix Pack is referred to as FP) you must only install and run the stored procedure that is attached on this SAP Note. Do not run the Online Table Move stored procedure that is part of DB2. For more information, make sure that you also read the Hot News SAP Note 1314293 . l Reinstall the stored procedure ONLINE_TABLE_MOVE after an upgrade to a higher DB2 Version or Fix Pack. l The option STATS_COPY is deprecated. l If the swap operation returns an error, you must cancel the stored procedure. l A major error was detected in DB2 V9 GA up to V9.1 Fix Pack 5 (in the following Fix Pack is referred to as FP). You can encounter a "BAD PAGE" error during roll forward operation. To avoid this problem, use the latest version of the stored procedure that is attached to this SAP Note. The problem did not occur with DB2 V9.5. For more information about this problem, see APAR IZ33174 and SAP Note 1256153 . You will also find additional information in section "Version History" at the end of this SAP Note. l Since 'IMPORT...REPLACE' (that is used to truncate tables on SAP systems) does not fire 'DELETE' triggers, the moved table might have more rows than the source table. This can lead to data inconsistencies. To solve this problem, we strongly recommended that you apply a new DBSL as described in SAP Note 1156597 . The same, 'ALTER TABLE...NOT LOGGED INITIALLY WITH EMPTY TABLE' does not fire 'DELETE' triggers. 1039544 - DB6: Stored procedure for online table move Version 114 Validity: 30.11.2011 - Language English Released On 30.11.2011 12:53:45 Release Status Released for Customer Component BC-DB-DB6 DB2 Universal Database for Unix / NT Priority Recommendations / Additional Info Category Special development

Upload: ji-yong-jung

Post on 02-Jun-2018

281 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: 0001039544

8/10/2019 0001039544

http://slidepdf.com/reader/full/0001039544 1/14

SAP Note

Header Data

Symptom

You want to move tables online between tablespaces using the stored procedure ONLINE_TABLE_MOVE.

Other Terms

online table move stored procedure, OTM, DB2 LUW

Reason and Prerequisites

l If you are using DB2 V9.7 or higher, call the SYSPROC.ADMIN_MOVE_TABLE stored procedure.For more information, see the DB2 V9.7 documentation and SAP Note 1543745.

l For Linux and UNIX only: You are using DB2 Version 8.2.2, DB2 Version 9.1 or DB2 Version 9.5.

l For Windows only: You are using DB2 Version 9.1 or DB2 Version 9.5.

l DB2 registry variable DB2_SKIPDELETED must be set to OFF.

l The SYSTOOLSPACE tablespace must be accessible for 'PUBLIC'.To make it accessible, enter the following command:

db2 "GRANT USE OF TABLESPACE SYSTOOLSPACE TO PUBLIC"l Read and understand the "Note" section below.

Solution

Related Concepts

l Incremental Conversion (SAP transaction ICNV) --> See SAP Note 963602

l Moving Tables Using Report DB6CONV --> See SAP Note 362325

Note:

l For DB2 Version 8.2.2, up to DB2 Version 9.1 Fix Pack 8 or up to DB2 Version 9.5 Fix Pack 5 (inthe following Fix Pack is referred to as FP) you must only install and run the storedprocedure that is attached on this SAP Note.Do not run the Online Table Move stored procedure that is part of DB2. For more information,make sure that you also read the Hot News SAP Note 1314293 .

l Reinstall the stored procedure ONLINE_TABLE_MOVE after an upgrade to a higher DB2 Version or FixPack.

l The option STATS_COPY is deprecated.

l If the swap operation returns an error, you must cancel the stored procedure.

l A major error was detected in DB2 V9 GA up to V9.1 Fix Pack 5 (in the following Fix Pack isreferred to as FP). You can encounter a "BAD PAGE" error during roll forward operation. To avoidthis problem, use the latest version of the stored procedure that is attached to this SAP Note.The problem did not occur with DB2 V9.5.For more information about this problem, see APAR IZ33174 and SAP Note 1256153 . You will alsofind additional information in section "Version History" at the end of this SAP Note.

l Since 'IMPORT...REPLACE' (that is used to truncate tables on SAP systems) does not fire 'DELETE'triggers, the moved table might have more rows than the source table. This can lead to datainconsistencies.To solve this problem, we strongly recommended that you apply a new DBSL as described in SAPNote 1156597 .The same, 'ALTER TABLE...NOT LOGGED INITIALLY WITH EMPTY TABLE' does not fire 'DELETE' triggers.

1039544 - DB6: Stored procedure for online table move

Version 114 Validity: 30.11.2011 -Language English

Released On 30.11.2011 12:53:45Release Status Released for CustomerComponent BC-DB-DB6 DB2 Universal Database for Unix / NTPriority Recommendations / Additional InfoCategory Special development

Page 2: 0001039544

8/10/2019 0001039544

http://slidepdf.com/reader/full/0001039544 2/14

This is only used in very rare cases in SAP BI Version <= 3.5. To avoid this, follow SAP Note1168893

l The online table move is by factors slower than the offline method.

l In an SAP environment, issue the stored procedure for an online table move as connect usersap<sapsid>db (Java), sap<sapsid> or sapr3 (ABAP).

l DB6CONV (version 4.0 or higher) provides easy access to the online table move stored procedure.To avoid errors, we recommend that you use DB6CONV instead of calling the stored procedure fromthe command line.

l If you want to copy tables in the Java database schema (sap<sapsid>db), you must use version 1.5of the stored procedure. Version 1.4 and lower will not copy the 'CCSID UNICODE' table attribute

that is used on tables in the Java database schema.l The online table move does not change the data types of columns. The data type mapping of the

data dictionary (DDIC) depends on the page size of the tablespace.If, for example, you create the table in a tablespace with a larger page size, the DDIC mappingmay change from CLOB to VARCHAR. If you move the table online using the stored procedureONLINE_TABLE_MOVE, the data types do not change. Even if the DDIC would create the tabledifferently, the table would still be accessible with SAP means.

l Tables without a unique index can also be moved online. In this case, many records can beprocessed in one REPLAY operations, so the REPLAY operation might be expensive. In raresituations UPDATE, DELETE or INSERT operations (UDI operations) can cause deadlocks.

l You can initiate multiple table moves of different tables in parallel. If you want to avoidfragmentation of the target tablespace, do NOT perform parallel moves into the same tablespace.

Goal

The main goal is to provide a method to move tables online during normal system operation, that is,the online table move should:

l Be fully recoverable

l Keep the offline window small to avoid system downtimes

l Perform regular COMMITs to avoid high active log space requirement

l Be usable in a HADR setup

However, be aware that:

l The stored procedure ONLINE_TABLE_MOVE requires a lot of space for:

¡ A staging table with one index to capture changes on the table

¡ A copy of the table including all indexes

¡ The stored procedure creates many log records to ensure recoverability.

l The online table move might be slow because fully logged operations are used to ensurerecoverability.

Limitations

The stored procedure does not support 'typed tables', 'materialized query tables' (MQTs) and 'rangeclustered tables' (RCTs). Be aware that 'typed tables', MQTs and RCTs are currently not used in SAPdatabases.

The following tables cannot be moved using the stored procedure:

l System tables

l The protocol table SAPTOOLS.ONLINE_TABLE_MOVE

l The semaphore table SAPTOOLS.OTM_SEMAPHORE_TABLE

l Tables of active event monitors

l Tables that have generated columns

l

Tables that are part of a foreign key relationship

Tables with generated columns, foreign key relationships and constraints other than 'UNIQUE' arecurrently not used in SAP databases.

Tables with LBAC attributes can be moved but the LBAC attributes are ignored. The stored proceduredoes not copy rights that were given or revoked using the GRANT or REVOKE commands.

Last but not least, the DB2 registry variable DB2_SKIPDELETED must be switched off, which is thedefault for SAP systems.

Page 3: 0001039544

8/10/2019 0001039544

http://slidepdf.com/reader/full/0001039544 3/14

Use Cases

You can use the stored procedure ONLINE_TABLE_MOVE if you want to:

l Overcome the tablespace limit - especially on DB2 Version 8 - by moving tables into seperatetablespaces.

l Tune system performance by moving tables into a seperate tablespace to allow assignment ofanother bufferpool to this tablespace.

l Solve concurrency problems with online backups. These concurrency problems can occur if the DB2registry variable DB2_OBJECT_TABLE_ENTRIES was not set when the original tablespace was created.

l

Move tables into different types of tablespaces (SMS, DMS, automatic storage).l Move tables into a tablespace with a different extent size, that is:

¡ You want to move empty or small tables into a tablespace with a small extent size to reducethe database size.

¡ You want to move large tables into a tablespace with a greater extent size to improve IOperformance.

l Move tables into a tablespace with a different page size, that is:

¡ You want to move empty or small tables into a tablespace with a small page size to savespace.

¡ You want to move tables with a large row size to a tablespace with a large page size toreduce unusable space on the pages.

l Reduce the high-water-mark of a tablespace if the right table has been moved.

l Separate unused and read-only tables, for example, to improve performance of incrementalbackups.

l Enable tables for the use of large record identifiers (RIDs) without downtime for indexrecreation.

l Move LONG/LOB data into a seperate tablespace. The advantages are as follows:

¡ The tablespace limit in DB2 Version 8 is bypassed.

¡ You can activate file system caching for the LONG tablespace for better LONG/LOB read

performance.l Move tables into a seperate tablespace to achieve 'table level recovery'.

l Compress or decompress a table using row compression without having to perform an offline REORG.

l Change characteristics of a table that you cannot change using the ALTER TABLE statement o r thatyou can change by using the ALTER TABLE statement BUT an offline REORG would be required.This includes:

¡ Add or remove multi-dimensional clustering (MDC)

¡ Add or remove range-partitioningRead SAP Note 1379362, before start using range-partitioning.

¡ Change the partitioning key

¡ Change the types of columns, for example, from LONG VARCHAR to VARCHAR

¡ Add or remove columns

¡ Change the order of columns

l Use an alternative to an 'INPLACE REORG' in cases where an INPLACE REORG has the followingconstraints:

¡ Online reorganization of MDC tables cannot be performed

¡ Online reorganization of LONG/LOB data cannot be performed

¡ You cannot control the final phase of the REORG (truncation and object replacement). Usingthe stored procedure ONLINE_TABLE_MOVE, you are able to control when this short offlinephase happens.

l Redistribute tables online in DPF systems

Stored Procedure Parameters

The stored procedure exists in 2 flavours: One with 8 input parametersand one with 10 input parameters.

Page 4: 0001039544

8/10/2019 0001039544

http://slidepdf.com/reader/full/0001039544 4/14

Flavour 1 - 8 input parameters:===============================

l TABSCHEMA VARCHAR(128)

l TABNAME VARCHAR(128)

l DATA_TBSP VARCHAR(128)

l INDEX_TBSP VARCHAR(128)

l LOB_TBSP VARCHAR(128)

l MDC_COLUMNS VARCHAR(32672)

l PARTKEY_COLS VARCHAR(32672)

l OPERATION VARCHAR(128)

Flavour 2 - 10 input parameters:================================

l TABSCHEMA VARCHAR(128)

l TABNAME VARCHAR(128)

l DATA_TBSP VARCHAR(32672)

l INDEX_TBSP VARCHAR(128)

l LOB_TBSP VARCHAR(32672)

l MDC_COLUMNS VARCHAR(32672)

l PARTKEY_COLS VARCHAR(32672)

l RANGE_PART VARCHAR(32672)

l COLDEF VARCHAR(32672)

l OPERATION VARCHAR(128)

Explanation of the parameters:==============================

l TABSCHEMA : Schema of table to be moved

l TABNAME : Name of table to be moved

l DATA_TBSP : Target data tablespace (must already exist)

l INDEX_TBSP : Target index tablespace (must already exist)

l LONG_TBSP : Target long tablespace (must already exist)

l MDC_COLUMNS : Target MDC column specification, for example: a,b

l PARTKEY_COLS: Target partitioning key, for example: a,b

l RANGE_PART : Range partitioning clause, for example: (b) (STARTING FROM (1) EXCLUSIVE ENDINGAT (1000) EVERY (100))

l COLDEF : Target column definition, for example: a int, b int default 0

l OPERATION : List of options, separated by commas The following options are possible:

¡ VERSION : Updates and returns the protocol table key 'CURRENT_VERSION'

¡ CANCEL : Cancels move operations

¡ INIT : Initiates the table move (target table, staging table and triggers are created)

¡ COPY : Copies table content and creates indexes

¡ REPLAY : Replays staging table information

¡ SWAP : Swaps the source with target table

¡ KEEP : Keeps original table

Page 5: 0001039544

8/10/2019 0001039544

http://slidepdf.com/reader/full/0001039544 5/14

¡ MOVE : Moves table (INIT+COPY+SWAP)

¡ CLEANUP : If the cleanup phase failes during the table swap, you can execute itseparately.

¡ TRACE : Generates a debug trace (not available in the DB2 V9.1 and DB2 V9.5 version ofthe stored procedure)

¡ STATS_NO : Does not perform RUNSTATS

¡ REORG : Performs an offline REORG before swapping table to get an optimal compressiondictionary and a fully reorganized table. This option issues an offline table REORG that isnot compatible with an online backup.

¡ COPY_WITH_INDEXES: Performs the copy phase after all indexes are created on the targettable.

¡ COPY_USE_LOAD: Copies the table using LOADA backup is required before the SWAP phase can be performed to ensure recoverability. SWAPneeds the option BACKUP_TAKEN to flag the need of a backup. For example "SWAP,BACKUP_TAKEN".

Protocol Table

You can use the protocol table SAPTOOLS.ONLINE_TABLE_MOVE to configure the online table movebehavior. The table is updated during the online table move and contains then status informationabout the progress of the online table move.

The table has the following columns:

l TABSCHEMA VARCHAR(128): Schema of table the attribute belongs to

l TABNAME VARCHAR(128) : Table name of the table the attribute belongs to

l KEY VARCHAR(128) : Attribute name

l VALUE VARCHAR(128) : Attribute value if the attribute value is <=128 characters. Otherwise,'NULL'.

l LONGVALUE CLOB(10M): Attribute value if the attribute value is > 128 characters. Otherwise,'NULL'.

Note:

If 'TABNAME' and 'TABSCHEMA' are empty strings, the attribute refers

to all online table moves.The table has the following attributes:

l CURRENT_VERSION: Latest version number of the stored procedure

l VERSION: Version number of stored procedure

l AUTHID: Authorization ID of the user who has called the stored procedure

l LOCK: Start time when the stored procedure was started

l STATUS: Status of online table movePossible values:

¡ INIT: Initialization is in progressTo undo the steps already performed, you an call the stored procedure with the 'CANCEL'option.

¡ COPY: Copy phase is in progressIn this state, you can call the stored procedure with the 'COPY' option. To undo stepsalready performed, use the 'CANCEL' option.

¡ REPLAY: REPLAY can be performedIn this state, you can call the stored procedure with the 'REPLAY' or 'SWAP' option. To undothe steps already performed, use the 'CANCEL' option.

¡ CLEANUP: Table move is complete, but cleanup is missing.In this state, you can call the stored procedure with the 'CLEANUP' option to complete themove.

¡ COMPLETE: Table move is complete.In this state, you can call the stored procedure withe the 'INIT' or 'MOVE' option again, toinitiate a further move.

l STAGING: Name of staging table

l TARGET: Name of target table

l ORIGINAL: Name of original table after 'SWAP'

l INDEXSCHEMA: Schema of index that is used to perform the replay. If 'INDEXSCHEMA' is an empty

Page 6: 0001039544

8/10/2019 0001039544

http://slidepdf.com/reader/full/0001039544 6/14

string, the table has no index.

l INDEXNAME: Name of index that is used to perform the replayIf 'INDEXNAME' is an empty string, the table has no index.

l COMMIT_AFTER_N_ROWS: Specifies after how many rows a COMMIT is performed during the copy phase.0 means, no COMMITs during copy. Default: 10000 rows

l TRACE: If the value is 0, tracing is disabled. Otherwise, tracing is enabled. This option only applies to the stored procedure that is attached to this SAP Note. This option is NOT part ofthe stored procedure being part of the DB2 product (DB2 V9.1 FP6 or higher and DB2 V9.5).

l INDEX_CREATION_TOTAL_TIME: Time (in seconds) required to create indexes

l INIT_START: Start time of initialization phase

l INIT_END: End time of initialization phase

l INIT_MAX_RETRIES: Maximum number of retries, if lock timeouts or deadlocks occured during theinit phase. Default: 10.

l INIT_RETRIES: Number of retries performed during init phase

l COPY_START: Start time of copy phase

l COPY_END: End time of copy phase

l COPY_TOTAL_ROWS: Number of rows that are copied during table copy phase. This attribute is alsoupdated during the copy phase to allow progress monitoring.

l REPLAY_START: Start time of replay phase

l REPLAY_END: End time of replay phase

l REPLAY_TOTAL_ROWS: Accumulated number of replayed rows

l REPLAY_TOTAL_TIME: Accumulated time in seconds used to replay rows

l REPLAY_MAX_ERR_RETRIES: Maximum retry count for errors (lock timeouts or deadlocks) that mightoccur during replay. Default: 10

l REPLAY_THRESHOLD: If in one iteration of the REPLAY_THRESHOLD operation less rows than thisnumber of rows have been applied, the REPLAY_THRESHOLD phase stops even if new entries were madein the meantime. Default: 100.

l REORG_START: Start time of optional REORG during swap phase

l REORG_END: End time of optional REORG during swap phase

l RUNSTATS_START: Start time of optional RUNSTATS (the default) during swap phase

l RUNSTATS_END: End time of optional REORG during swap phase

l SWAP_START: Start time of swap phase

l SWAP_END: End time of swap phase

l SWAP_MAX_RETRIES: Maximum number of retries, if lock timeouts or deadlocks occured during theswap phase. Default: 10.

l SWAP_RETRIES: Number of retries performed during swap phase

l CLEANUP_START: Start time of cleanup phase

l CLEANUP_END: End time of cleanup phase

l CLEANUP_MAX_RETRIES: Maximum number of retries, if lock timeouts or deadlocks occured duringthe cleanup phase. Default: 10.

Installation

Installation on DB2 Version 8.2.2, up to DB2 V9.1 FP8 or up to DB2 V9.5 FP5

Note: Reinstall the stored procedure ONLINE_TABLE_MOVE after an upgrade to a higher DB2 Version or FixPack.

To install the stored procedure ONLINE_TABLE_MOVE, proceed as follows:

1. Download one of the attached files depending on your operating system platform:

¡ AIX and LINUX: online_table_move_sp_<version>_1.tgz

Page 7: 0001039544

8/10/2019 0001039544

http://slidepdf.com/reader/full/0001039544 7/14

¡ HP and SUN: online_table_move_sp_<version>_2.tgz

¡ Windows: online_table_move_sp_<version>.zip (DB version folders DB2_V91 and DB2_V95, thensubfolders ntintel for x86 32-bit version, and ntamd64 for x64 64-bit version).

2. Extract the downloaded files.

3. Log on to the database server as instance owner.

4. Stop the database instance using db2stop (only required if you already used an earlierversion of ONLINE_TABLE_MOVE).

5. Copy the extracted online_table_move_sp(.dll) file to the following directories:

¡ UNIX:

1.) < INSTHOME>/sqllib/function 2.) < INSTHOME>/sqllib/function/unfenced

¡ Windows:

1.) < DB2PATH>\sqllib\function 2.) < DB2PATH>\sqllib\function\unfenced

6. Start the database instance again using db2start (only required if you had to stop thedatabase instance to replace existing ONLINE_TABLE_MOVE).

7. Connect to the database using the following command: db2 connect to <dbsid>

8. To catalogue the stored procedure for an online table move, call the stored procedure asfollows: db2 invoke online_table_move_sp

Installation of the stored procedure as part of DB2

For DB2 V9.1 FP9 or higher and DB2 V9.5 FP6 or higher, the storedprocedure is already part of DB2.To catalogue the stored procedure for an online table move, enter the following command as theinstance owner: db2 invoke db2sap

Using the Stored Procedure ONLINE_TABLE_MOVE

To move a table from one tablespace to another tablespace, enter thefollowing command:db2 "call SAPTOOLS.ONLINE_TABLE_MOVE(<table schema>,<table name>, <target data tablespace>, <target index tablespace>,'','','','MOVE')"

Problem Determination

In case of an error, the stored procedure returns an SQL0443N message. You can find the reason ofthe error in the diagnostics text section. The diagnostics text can only be 80 characters long andit is therefore often truncated. The full error message is written to the db2diag.log.

The following list lists the SQLSTATEs that are specific to the online table move procedure:38000: DB2_SKIPDELETED not allowed.-- > User response: Turn off DB2 registry variable DB2_SKIPDELETED and retry. 38001: Unknown data type.--> User response: Create a customer message in SAP Service Marketplace.38002: Name collision expected with <name of object>.--> User response: Check if you can drop the object in question.38003: Not in right state.--> User response: Check the OPERATION parameter according to the STATUS.38004: Not allowed on SYSIBM.--> Explanation: Online table move cannot be performed on system tables.38005: Table not supported.--> Explanation: The table type is not supported.38006: Cannot move online table move protocol table.--> Explanation: Online table move cannot move its own protocol table.38007: Tables are different.--> User response: Create a customer message in SAP Service Marketplace.38008: XML not supported.--> Explanation: Tables with XML columns and without an unique index can be moved.38009: Online table move not ongoing.--> Explanation: No online table move is ongoing and therefore the specified operation is notallowed.--> User response: Check the OPERATION parameter according to the STATUS.38010: Unable to determine DIAGPATH.--> User response: Create a customer message in SAP Service Marketplace.38011: Unknown table flag.--> User response: Create a customer message in SAP Service Marketplace.38012: Table locked by other online_table_move.--> Explanation: Another online table move is ongoing. No parallel online table move on the sametable allowed. Reason could also be an aborted call of the stored procedure due to forceapplication, Ctrl+C or a database restart.--> User response: If no other online table move is active, apply the steps described in the"Removing Online Table Move Locks" section.38013: Missing index info in protocol table.--> User response: Create a customer message in SAP Service Marketplace.38014: No data found.--> User response: Create a customer message in SAP Service Marketplace.38015: Staging table not empty.

Page 8: 0001039544

8/10/2019 0001039544

http://slidepdf.com/reader/full/0001039544 8/14

--> User response: Create a customer message in SAP Service Marketplace.38016: Internal error.--> User response: Create a customer message in SAP Service Marketplace.38017: Load used. Perform backup and use BACKUP_TAKEN option on retry.--> User response: Perform backup and call the stored procedure again with "SWAP,BACKUP_TAKEN" inthe operation parameter.38018: Table of active event monitor cannot be moved.--> User response: If possible, deactivate the event monitor to move the the table.38019: Table is or was part of an online table move.--> Explanation: You tried to issue a move on a table that is used as internal table during anothermove operation.38020: DB release does not support transfer of owner.--> Explanation: The stored procedure cannot continue because the move requires a TRANSFER OWNERSHIPcommand that is not supported in DB2 Version 8.--> User response: Call the stored procedure as the owner of the table.38021: tables differ, differences can be fixed.--> User response: Create a customer message in SAP Service Marketplace.

38022: tables differ, differences cannot be fixed.--> User response: Create a customer message in SAP Service Marketplace.

38023: DB2 version not supported.--> Explanation: The stored procedure is only supported on DB2 8.2.2 / 9.1 and higher.--> User response: Update your database to at least DB2 Version 8.2.2 / V 9.138024: Generated columns not supported.--> Explanation: Tables that have generated columns are not supported.38025: Index generation failed.--> Explanation: The table does not have an index and the index generation algorithm of theprocedure was not able to create an index.--> User response: Manually create a non-unique index and restart the table move.38026: Replay not complete. Reason: <sqlcode>--> Explanation: The REPLAY was not able to process all rows in the staging table because too manylocks are active on the staging table. In '<sqlcode>', you can find the SQL code of the actualerror.--> User response: Retry the REPLAY in a time with less UDI activity on the table.38027: Source table recreated during move.--> Explanation: The source table was dropped and recreated during the online table move.--> User response: Cancel and then restart the online table move.380028: Init maximum retries exceeded.--> Explanation: Internal loop during INIT reached the maximum number.--> User response: Cancel and then restart the online table move.380029: Swap maximum retries exceeded.--> Explanation: Internal loop during SWAP reached the maximum number.--> User response: Restart the online table move with the SWAP option.380030: Invalid CLUSTER option.--> Explanation: Invalid CLUSTER options was specified.--> User response: Call online table move with valid options.380031: Optimizer hint could not be applied.--> Explanation: An internal generated optimmizer hint was ignored.--> User response: Create a customer message in SAP Service Marketplace.

380032: Cleanup maximum retries exceeded.-- > Explanation: Internal loop during CLEANUP reached the maximum numbe --> User response: Restart the online table move with the cleanup option.380033: Unique index is missing-- > Explanation: An unique index on the source table is required. --> User response: Create an unique index on the source table. Cancel and restart the online tablemove.

Problem Reporting

In case of a problem, proceed as follows:

1. Generate a trace file which is required for problem analysis.

2. Provide the DDL of the table that you wanted to move.

3. Provide the content of the SAPTOOLS.ONLINE_TABLE_MOVE protocol table.

4. Provide the content of the SAPTOOLS.OTM_SEMAPHORE_TABLE table.

5. Collect the data as described below and open a customer message that contains the trace andthe DDL file in SAP Service Marketplace.

Generating Trace Output on DB2 V8.2.2 or higher, DB2 V9.1 up to FP8 and DB2 V9.5 up to FP5

To generate a trace file, run the stored procedure wi th the additional option 'TRACE' as follows:db2 "call SAPTOOLS.ONLINE_TABLE_MOVE(<table schema>,<table name>, <target data tablespace>, <targetindex tablespace>,'','','','MOVE,TRACE')"

The trace file is generated in the DIAGPATH with a the following name, for example, otm_ <tableschema>_<table name>_<operation>.trc. All special character are replaced by '_'.

The statement above would generate a trace file with the name otm_<table schema>_<tablename>_MOVE_TRACE.trc.

Generating Trace Output of the stored procedure as part of DB2

The DB2 versions of the stored procedure (installed through: "db2 invoke db2sap") uses the DB2 tracefacility.To activate tracing, enter the following command: db2trc on -m "*.*.140.*.*" -f <trace file>The "-m" option limits the tracing to a minimum because only one module is enabled.After you have called the stored procedure, enter the following command: db2trc off

Page 9: 0001039544

8/10/2019 0001039544

http://slidepdf.com/reader/full/0001039544 9/14

Reproducing the Problem With a DDL

In addition, to reproduce the probem, the DDL of the table involved is required. To generate theDDL, enter the following command: db2look -d <database alias> -z <table schema> -t<table name> -e -m-o <table name>.ddl

Extracting the Contents of the Protocol Table

Export the protocol table using, for example, the following command: db2 "export to <table name>.ixfof ixf select * from saptools.online_table_move"

Extracting the Contents of the Sempaphore Table

Export the semaphore table using, for example, the following command: db2 "export to <tablename>.ixf of ixf select * from saptools.otm_semaphore_table"

Known Issues and Workarounds

Removing Online Table Move Locks

If you use Ctrl+C or "force application" to stop the stored procedure, the "LOCK" entry is notremoved from the SAPTOOLS.ONLINE_TABLE_MOVE protocol table.

Further calls of the stored procedure fail with the message "Table locked by otheronline_table_move" (SQLSTATE 38012).

The "LOCK" entry should only be deleted if there is clearly no stored procedure ONLINE_TABLE_MOVErunning. To delete the lock entry, issue following command: db2 "delete fromSAPTOOLS.ONLINE_TABLE_MOVE where tabschema ='<table schema>' AND tabname = '<table name>' AND key ='LOCK'"

Object Ownership

Newly created objects are owned by the creator of the objects. The stored procedure tries to ensurethat the original ownership and the access permission are retained for the moved table.

l DB2 V9.1 or higher:To guarantuee the correct ownership, the stored procedure issues "TRANSFER OWNERSHIP" calls. ForTRANSFER OWNERSHIP calls, you require the SECADM authority if the issuers of TRANSFER OWNERSHIPis not the owner of the object. You can grant SECADM authority using, for example, the followingcommand:db2 "GRANT SECADM ON DATABASE TO USER <user>"

l DB2 Version 8:DB2 Version 8 does not support the "TRANSFER OWNERSHIP" command. Therefore, you must call thestored procedure as the owner of the table. To get execution permission to ONLINE_TABLE_MOVE,run the INVOKE command as the owner of the table. On SAP systems, the table owner is typicallythe ABAP connect user sap <sapsid> (or sapr3) or the Java connect user sap<sapsid>db. Sometables are owned by the <sapsid>adm user.

SQL Return Code SQL0443N

SQLCODE 38021 (after migration to DB2 Version 9.1 or higher):

The stored procedure ONLINE_TABLE_MOVE returns the SQL-error SQL0443N with the following diagnostictext:SQL0443N Routine "ONLINE_TABLE_MOVE" (specific name "ONLINE_TABLE_MOVE") has returned an errorSQLSTATE with diagnostic text "Table layout different (fixable)". SQLSTATE=38021The trace file shows different entries for the source table and target table at entry point"SQLT_db2sap_Otm_getStatsOpts".For the source table, the entry point looks as follows:"RUNSTATS ON TABLE "SAPR3"."AFIH" WITH DISTRIBUTION ON ALL COLUMNS AND DETAILED INDEXES ALL"For target table, the entry point looks as follows:"RUNSTATS ON TABLE "SAPR3"."AFIHAABFrYt" ON ALL COLUMNS WITH DISTRIBUTION ON ALL COLUMNS ANDDETAILED INDEXES ALL"

Reason:

The default behavior of DB2 V9.1 or higher for the syntax of the statistic profile has changed.

The following stored procedure call results in the following statisticprofile:

l Call of stored procedure:db2 "CALL ADMIN_CMD('RUNSTATS ON TABLE <schema.name> WITH DISTRIBUTION ON ALL COLUMNS ANDDETAILED INDEXES ALL')"

l Statistic profile:db2 "RUNSTATS ON TABLE <schema.name> ON ALL COLUMNS WITH DISTRIBUTION ON ALL COLUMNS ANDDETAILED INDEXES ALL"

Solution:

Page 10: 0001039544

8/10/2019 0001039544

http://slidepdf.com/reader/full/0001039544 10/14

To get the DB2 Version 9.1 or higher behavior for source tables generated on older DB2 versions,refresh the statistic profile on that table. To do this, execute the following command as userdb2<dbsid>:db2 "SELECT statistics_profile FROM SYSCAT.TABLES WHERE tabschema ='<schema>' and tabname ='<name>'"Refresh the statistic profile with the result set using the following command:db2 "CALL ADMIN_CMD('<resultset_of_the_select_statement> SET PROFILE ONLY')"

SQLCODE 3855 (DB2 Version 8 only):

ONLINE_TABLE_MOVE returns SQL0443N with diagnostic text as follows:"SQL0443N Routine "*_TBLNDEP" (specific name "") has return". SQLSTATE=3855 db2diag.log shows following entry:SQL0443N Routine "*_TBLNDEP" (specific name "") has returned an error SQLSTATE with diagnostic text"SQL0551 Reason code or token: <USER>,USAGE,SYSTOOLS.DB2LOO ". SQLSTATE=3855 Where <user> is the connect user sap<sapsid> or sapr3.

Reason:

Online_TABLE_MOVE was previously called with wrong user and return code: "DB release does notsupport transfer of owner". SQLSTATE=38020 You might have database objects with insufficient grants.

Solution:

Rebind/Grant the following objects to the connect user <user>:sap<sapsid> or sapr3.To do this, run these commands as db2<dbsid>:db2 "bind sqllib/bnd/db2lk390.bnd grant <user>"db2 "bind sqllib/bnd/db2lkfun.bnd grant <user>"db2 "bind sqllib/bnd/db2lksp.bnd grant <user>"db2 "bind sqllib/bnd/db2look.bnd grant <user>"db2 "grant all on table SYSTOOLS.DB2LOOK_INFO to user <user>"db2 "grant all on table SYSTOOLS.DB2LOOK_INFO_V to user <user"db2 "grant execute on PROCEDURE SYSPROC.DB2LK_TBLNDEP to user <user>"db2 "grant execute on PROCEDURE SYSPROC.DB2LK_CLEAN_TABLE to user <user> "db2 "grant execute on FUNCTION SYSPROC.DB2LK_DEP_FIRST to user <user>"db2 "grant execute on FUNCTION SYSPROC.DB2LK_DEP_OF to user <user>"db2 "grant usage on sequence SYSTOOLS.DB2LOOK_TOKEN to user <user>"

Reference

Version History

1 .0

l Initial release

1.2, same as DB2 V9.5 GA

l Solved problems

¡ The problem that occurred when you called the stored procedure with TRANSFER OWNERSHIP andyou were NOT logged on as connect user sap <sapsid> or sapr3 was solved.

1 .4

l Solved problems

¡ You might receive confusing error messages if you call the table move and it is executed inmultiple steps and you call the stored procedure with wrong options.

¡ You can now move tables that have column names with 128 character length.

l Enhancements

¡

If tables have DECIMAL columns, performance improves.¡ RUNSTATS commands are executed with UTIL_IMPACT_PRIORITY 50.

¡ The output for the "name collision detected" error was improved. It now contains the tablename that caused the error.

¡ The STATS_COPY option was introduced. This option causes statistics to be copied instead ofbeing newly generated by a RUNSTATS command.

¡ Introduced COPY_WITH_INDEXES option, that is, indexes are created before the COPY phase.

1 .5

l Solved Problems

¡ Avoids the problem that generated indexes can exceed the maximum key length. This correctiononly applies to tables that have no index.

¡ The CCSID table attribute is now copied. The CCSID table attribute is used for tables in theJava database schema.

¡ The RESTRICT ON DROP table attribute is now copied.

¡ Deadlocks could occur during the SWAP phase, because of a wrong handling of lock timeouts.

Page 11: 0001039544

8/10/2019 0001039544

http://slidepdf.com/reader/full/0001039544 11/14

This has been corrected.

l Enhancements

¡ The row compression dictionary is now created based on a table sample instead of the firstrows in the source table. This will improve the quality of the row compression dictionarysignificantly.

1.6, same as DB2 V9.5 FP1

l Solved problems

¡ With previous versions, you might have received the following error messsage on multi-partitioned systems if you move tables with row compression enabled:

SQL1142N The operation cannot complete because the file "o" 1 .7

l Solved Problems

¡ With previous versions, tables without an index could not be moved if the schema name of thetable has less than 8 characters.The error message was as follows:SQL0204N "<schema>.<tabname><some chars>t" is an undefined name. SQLSTATE=4270

1 .8

l Solved Problems

¡ With previous versions, you might have encountered a deadlock during the initialization ofthe COPY phase because of APAR IY97310.The code was changed, that is, no "IMPORT from /dev/null" is issued on the staging table.

¡ In addition, if you use DB2 Version 9.1 FP1, FP2 or FP3, the cleanup of the target table isdone by a blockwise DELETE operation instead of "IMPORT from /dev/null".

l Enhancements

¡ The "before update" trigger has been changed that it is only activated if key columns aremodified.

1 .9

l Solved Problems

¡

With previous versions, if REPLAY failed, the protocol table entries REPLAY_TOTAL_ROWS andREPLAY_TOTAL_TIME were not updated.

¡ The DB2_SKIPDELETED check is no longer performed on CLEANUP calls.

¡ SQLSTATE reported if an error occurred with 4 instead of 5 characters.

l Enhancements

¡ A new REPLAY algorithm was introduced to skip rows on the staging table where a lock isactive.

¡ If the REPLAY algorithm fails because it was not be able to process all rows due to locksstill being active on the staging table, the procedure now returns SQLSTATE 38026 instead of'-911' error messages.

¡ The original table name appears in the protocol table if the KEEP option is used.

2.0, same as DB2 V9.5 FP2

l Enhancements

¡ A new trigger implementation ensures that 'UPDATE/DELETE/INSERT' (UDI) operations on thesource table have a good performance and that bottlenecks in temporary object handling areavoided.

2 .1

l Solved Problems

¡ With previous versions, tables with an clustered index could not be moved with the option

COPY_WITH_INDEXES.The error message was:SQL1581N The table "<schema>.<some chars>t" cannot be in app. SQLSTATE=428CA

2 .2

l Solved Problems

¡ Moving tables with LONG VARCHAR columns could generate various errors and SQLSTATE=07006.

Page 12: 0001039544

8/10/2019 0001039544

http://slidepdf.com/reader/full/0001039544 12/14

2.3, same as DB2 V9.1 FP6 and DB2 V9.5 FP3

l Enhancements

¡ Source tables with unique indexes and no primary key:The index selection for staging table improved.

2 .4

l Solved Problems

¡ With 'Online Table Move' the SQL 'DELETE' command is used instead of the 'TRUNCATE' commandto avoide the error described in DB2 APAR IZ33174. For more details, see SAP Note 1256153.This code correction is valid on DB2 V9.1 up to FP5. The SQL 'Truncate' command is used

again starting as of DB2 V9.1 FP6.l Enhancements

¡ Improved deadlock prevention in combination with automatic RUNTSTATS.

¡ Support of clustering table by secondary index.

2 .5

l Solved Problems

¡ With previous versions, tables with LONG VARCHAR columns and cluster index could fail increating a unique index on the source table (DB2 V9.1 only).

¡

The use of SQL 'DELETE' in Version 2.4 leeds to problems when the table is in APPEND mode.Now APPEND mode is forced to off.

l Enhancements

¡ Tables with distribution key and no unique index are supported.

¡ Improved performance and Deadlock prevention during COPY phase.

2.6, same as DB2 V9.1 FP7 and DB2 V9.5 FP4

l Solved Problems

¡ Comparing of PCTFREE -1 and 0 was previously considered as different.

¡ Now, option COPY_USE_LOAD can be called with redefinition of columns.

l Enhancements

¡ Recoverability improved when SWAP phase failed.

¡ Improved deadlock prevention in combination with automatic RUNTSTATS.

2 .7

l Solved Problems

¡ With previous versions, tables with unique cluster index could fail during the COPY phase.

l Enhancements

¡ Improved index on the staging table reduces the risk of failure during parallel inserts intothe source table.

2 .8

l Solved Problems

¡ With previous versions, under very specific circumstances the OTM procedure might not copyall modified data records from the source table to the target table. For more information,see also SAP Note 1314293.

2 .9

l Solved Problems

¡ Nullable columns on the staging table could generate SQLCODE -99999 during the swapoperation. This behaviour could be forced during parallel inserts into the source table.

l Enhancements

¡ A new locking mechanism on the source table minimizes the posibility of a deadlock duringthe swap operation.

3.0, same as DB2 V9.1 FP8

Page 13: 0001039544

8/10/2019 0001039544

http://slidepdf.com/reader/full/0001039544 13/14

l Solved Problems

¡ If any UDI trigger is missing, SWAP now returns SQL0204N during trigger dropping.

l Enhancements

¡ Reduced locking if no unique index on source table.

3.1, same as DB2 V9.5 FP5

l Solved Problems

¡ Deadlocks during parallel calls to online table move are now unlikely. Critical paths areserialized.

l Enhancements

¡ Optimizer hints during SELECT statement in COPY phase forces an index scan.

3.2, same as DB2 V9.1 FP9

l Solved Problems

¡ The option UTIL_IMPACT_PRIORITY is now supported in the RUNSTATS PROFILE of the sourcetable.

l Enhancements

¡ New copy algorithm to improve the performance during the copy phase.

3.3, same as DB2 V9.1 FP10 and DB2 V9.5 FP6

l Solved Problems

¡ Secondary Unique Indexes on the source table could generate SQL0803N during REPLAY on thetarget table.

l Enhancements

¡ New Operation 'VERSION' updates the protocol table key 'CURRENT_VERSION' with the latestversion.

3.4, same as DB2 V9.1 FP11 and DB2 V9.5 FP9

l

Solved Problems¡ Returns SQL0969N / SQL1188N / SQL0408N error code as described in DB2 APAR IC782851

¡ Recreating the target table before SWAP phase will now force an error.

l Enhancements

¡ Improved overall performance

¡ Protocol RUNSTATS and REORG start/end time

ValidityThis document is not restricted to a software component or software component version

References

This document refers to:

SAP Notes 1099936 DB6: SQL0670N The row length of a table exceeds 4005 bytes 1156597 DB6: TRUNCATE TABLE on table with DELETE TRIGGER 1168893 DB6: Adjusting SAP BI compression to Online Table Move 1256153 DB6: Rollforward may fail "Page count incorrect during redo" 1314293 DB6: Potential data loss when running Online Table Move 1379362 DB6: Support for partitioned tables in the ABAP DDIC 1430621 DB6: Performance of VBDATA 1508151 DB6: SQLADM authority needed for ADMIN_MOVE_TABLE 1513862 DB6: Table conversion using DB6CONV Version 5.01 or higher 1543745 DB6: Using and troubleshooting ADMIN_MOVE_TABLE

Page 14: 0001039544

8/10/2019 0001039544

http://slidepdf.com/reader/full/0001039544 14/14

This document is referenced by:

SAP Notes (13)

Attachments

1543754 Event: Trace during deactivation of event linkage 362325 DB6: Table conversion using DB6CONV Version 4.10 or lower 817709 DB6: DB6CONV: Complete version history Version 4.10 or lower 963602 DB6: Moving tables online

1099936 DB6: SQL0670N The row length of a table exceeds 4005 bytes 1543745 DB6: Using and troubleshooting ADMIN_MOVE_TABLE 1543754 Event: Trace during deactivation of event linkage 1379362 DB6: Support for partitioned tables in the ABAP DDIC 963602 DB6: Moving tables online 1314293 DB6: Potential data loss when running Online Table Move 1168893 DB6: Adjusting SAP BI compression to Online Table Move 1156597 DB6: TRUNCATE TABLE on table with DELETE TRIGGER 1256153 DB6: Rollforward may fail "Page count incorrect during redo" 1513862 DB6: Table conversion using DB6CONV Version 5.01 or higher 1508151 DB6: SQLADM authority needed for ADMIN_MOVE_TABLE 817709 DB6: DB6CONV: Complete version history Version 4.10 or lower 362325 DB6: Table conversion using DB6CONV Version 4.10 or lower

File Name File Size (KB) Mime Typeonline_table_move_spV34_1.tgz 716 application/octet-stream

online_table_move_sp_V34.zip 682 application/x-zip-compressed

online_table_move_spV34_2.tgz 1581 application/octet-stream