Search code examples
djangodb2ibm-clouddb2-luw

DB2 And Django - Why Tables Always Created As Column Organized?


I have used the steps mentioned in the answer to this question Django connect to IBM Cloud database.

But all the tables are getting created as column organized which creates issues while altering the table, and this issue is for the initial migrate itself admin, auth, contenttypes, etc.

Can we somehow change the table creation to row organized?

Specifically, I get the below-mentioned error:

django.db.utils.ProgrammingError: Exception('Statement Execute Failed: [IBM][CLI Driver][DB2/LINUXX8664] SQL1667N The operation failed because the operation is not supported with the type of the specified table. Specified table: ".DJANGO_CONTENT_TYPE". Table type: "ORGANIZE BY COLUMN". Operation: "ALTER TABLE". SQLSTATE=42858\r SQLCODE=-1667')


Solution

  • Your question does not mention your cloud detail, specifically if it a shared or private Db2-instance etc. Also you may be using Db2 warehouse on cloud which may be configured for analytics workloads which often use organize by column for tables by default.

    Database configuration and Db2-instance configuration for shared usage may be preconfigured (by IBM) for cloud instances, and you may not be able to change them.

    On the Db2-instance, the Db2-registry variable setting DB2_WORKLOAD=ANALYTICS and the database parameter dft_table_org can determine the default table organization. You can query these values (if you have relevant permissions and relevant access), either by table functions with SQL, or by having shell access to a private Db2-instance.

    For shared databases or shared Db2-instances, you can arrange for your CREATE TABLE statements DDL to always include ORGANIZE BY ROW for tables that are for OLTP type processing.