{"record":{"id":"ccc56c0d118d9fc1","repo":"apache/cassandra","slug":"cannot-alter-table-id","errorCode":null,"errorMessage":"Cannot alter table id.","messagePattern":"Cannot alter table id\\.","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/statements/schema/TableAttributes.java","lineNumber":99,"sourceCode":"\n    public void validate()\n    {\n        validate(validKeywords, obsoleteKeywords);\n        build(TableParams.builder()).validate();\n    }\n\n    TableParams asNewTableParams(String keyspaceName)\n    {\n        TableParams.Builder builder = TableParams.builder();\n        if (!hasOption(TRANSACTIONAL_MODE) && !SchemaConstants.isSystemKeyspace(keyspaceName) && Schema.instance.distributedKeyspaces().names().contains(keyspaceName))\n            builder.transactionalMode(DatabaseDescriptor.defaultTransactionalMode());\n        return build(builder);\n    }\n\n    TableParams asAlteredTableParams(TableParams previous)\n    {\n        if (getId() != null)\n            throw new ConfigurationException(\"Cannot alter table id.\");\n        return build(previous.unbuild());\n    }\n\n    public TableId getId() throws ConfigurationException\n    {\n        String id = getString(ID);\n        try\n        {\n            return id != null ? TableId.fromString(id) : null;\n        }\n        catch (IllegalArgumentException e)\n        {\n            throw new ConfigurationException(\"Invalid table id\", e);\n        }\n    }\n\n    public static Set<String> validKeywords()\n    {","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/statements/schema/TableAttributes.java#L81-L117","documentation":"A table's id is its immutable unique identifier (TableId). TableAttributes.asAlteredTableParams() rejects any ALTER TABLE that tries to change the `id` table attribute, throwing ConfigurationException, because altering it would break references (hints, schema history, etc.).","triggerScenarios":"ALTER TABLE t WITH id = 'xxxxxxxx-....' — the id attribute present on an ALTER statement.","commonSituations":"Attempting to 're-link' a table after restore/clone; copying full CREATE TABLE options (including id) into an ALTER; migration tooling rewriting ids.","solutions":["Remove the id option from the ALTER TABLE statement","To get a new table id, recreate the table and copy the data (e.g. INSERT/COPY or a new CREATE TABLE + migration)"],"exampleFix":"// before\nALTER TABLE ks.t WITH id = '1a2b3c4d-0000-4000-8000-000000000000';\n// after\nALTER TABLE ks.t WITH comment = 'metadata update'; -- drop the id option","handlingStrategy":"validation","validationCode":"function validateAlterTable(attrs) {\n  if (attrs && attrs.id !== undefined) throw new Error('Table id is immutable; remove it from ALTER TABLE');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never include id in ALTER TABLE attribute sets","When copying CREATE TABLE options, strip the id attribute","To change a table id, create a new table and migrate data"],"tags":["cql","table","immutable","validation"],"backgroundTag":"unsupported-operation","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}