{"record":{"id":"5f0355ebc50c3c3f","repo":"cube-js/cube","slug":"mysql-can-not-work-with-table-names-longer-than-64","errorCode":null,"errorMessage":"MySQL can not work with table names longer than 64 symbols. Consider using the 'sqlAlias' attribute in your cube definition for ${quotedTableName}.","messagePattern":"MySQL can not work with table names longer than 64 symbols\\. Consider using the 'sqlAlias' attribute in your cube definition for (.+?)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/cubejs-mysql-driver/src/MySqlDriver.ts","lineNumber":285,"sourceCode":"    promise.cancel = () => cancelObj.cancel();\n    return promise;\n  }\n\n  public async testConnection() {\n    // eslint-disable-next-line no-underscore-dangle\n    const conn: MySQLConnection = await (<any> this.pool)._factory.create();\n\n    try {\n      return await conn.execute('SELECT 1');\n    } finally {\n      // eslint-disable-next-line no-underscore-dangle\n      await (<any> this.pool)._factory.destroy(conn);\n    }\n  }\n\n  public async createTable(quotedTableName: string, columns: TableColumn[]): Promise<void> {\n    if (quotedTableName.length > 64) {\n      throw new Error('MySQL can not work with table names longer than 64 symbols. ' +\n        `Consider using the 'sqlAlias' attribute in your cube definition for ${quotedTableName}.`);\n    }\n    return super.createTable(quotedTableName, columns);\n  }\n\n  public async query(query: string, values: unknown[]) {\n    return this.withConnection(async (conn) => {\n      await this.setTimeZone(conn);\n\n      return conn.execute(query, values);\n    });\n  }\n\n  protected setTimeZone(conn: MySQLConnection) {\n    return conn.execute(`SET time_zone = '${this.config.storeTimezone || '+00:00'}'`, []);\n  }\n\n  public async release() {","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-mysql-driver/src/MySqlDriver.ts#L267-L303","documentation":"MySQL limits table (and identifier) names to 64 characters. MySqlDriver.createTable pre-checks the quoted table name length and refuses to create pre-aggregation/temp tables that exceed it, pointing the user at the `sqlAlias` cube attribute as the remedy.","triggerScenarios":"A pre-aggregation (rollup) table is uploaded via `uploadTableWithIndexes` -> `createTable`, where the generated quoted table name (derived from cube/pre-aggregation naming) exceeds 64 characters.","commonSituations":"Cubes with very long names or long pre-aggregation names in multi-tenant setups where prefixes/segment names are appended to the rollup table name.","solutions":["Add `sqlAlias: 'short_name'` to the cube definition in the data model to shorten the generated table name.","Shorten the cube name or pre-aggregation name in the schema.","Shorten any deployment prefix (e.g., CUBEJS_DB_NAME or schema prefix) contributing to the identifier.","If unavoidable, use a database with a longer identifier limit."],"exampleFix":"// before\ncube('VeryLongSalesTransactionsForNorthAmericaRegionalReporting', { /* ... */ });\n// after\ncube('VeryLongSalesTransactionsForNorthAmericaRegionalReporting', {\n  sqlAlias: 'sales_tx_na',\n  /* ... */\n});","handlingStrategy":"validation","validationCode":"if (quotedTableName.length > 64) {\n  throw new Error(`Table name exceeds MySQL's 64-char limit: ${quotedTableName}. Add sqlAlias to the cube.`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await driver.createTable(name, columns);\n} catch (e) {\n  if (e.message.includes('longer than 64')) {\n    console.error('Add sqlAlias to the cube definition');\n  }\n  throw e;\n}","preventionTips":["Always set sqlAlias on cubes with long names.","Keep cube and pre-aggregation names short.","Validate identifier lengths in CI for all target databases.","Mind deployment prefixes when naming schemas."],"tags":["mysql","identifier-length","pre-aggregation","schema"],"backgroundTag":"identifier-too-long","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}