Table ID not preserved using CREATE OR REPLACE TABLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2025 10:44 AM
The When to replace a table documentation states that using CREATE OR REPLACE TABLE should preserve the table’s identity:
Table contents are replaced, but the table identity is maintained.
However, in my recent test the table ID changed after running this command. Is this expected behavior?
For example, the transaction log shows:
Version 0:
{"metaData":{"id":"6a085d18-3aef-4c4c-890b-fb4a6f9d6888", ...}}Version 2: (post command)
{"metaData":{"id":"e3f5d990-2c03-483e-8cd3-a772d5d87e93", ...}}
Should CREATE OR REPLACE TABLE ever generate a new table ID, or is this a bug?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2025 11:47 AM
Yes that's correct. The table identity is preserved in case of delta tables. If the table is non delta it will not be preserved.
Can you also confirm if the table you are recreating have schema changes. Because sometimes CREATE OR REPLACE TABLE with change in column definitions, table properties or format may be treated as drop and recreate operation internally which might result in id lost.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2025 01:13 PM - edited 09-30-2025 01:15 PM
HI @nayan_wylde , @shanisolomonron
I don't think it works in the way you've described. We can easily check this. Each time I execute following code I get new id:
%sql
CREATE OR REPLACE TABLE databricks_demo_ws.default.my_table (
id int,
name string
)So, first time I've exectued above code I got id: f2a57c4-152b-46c4-9dd5-b1e945846d71
Then I execute above code second time. As you can see, no major schema changes occured but still I got completly new id: 641cacab-7175-4f44-98cc-fad9ba8aa66e
I think what they refer in docs as table identity is more related to catalog / metadata identity (not necessarily the same as the internal delta log id). Because all other things mentioned in documentation hold:
- The table history is retained, and I can revert the table to an earlier version with the RESTORE command.
- The operation is a single transaction, so there is never a time when the table doesn't exist.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2025 01:38 PM
Waiting for a databricks employee to clarify this item.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2025 09:42 PM
In a UC-managed table, when you check the table properties and look at the storage path
-
eg: if the Storage path is
s3://my_uc_bucket_kr/ae32f4d9-3c84-4583-9197-ffadf942bdf4d/tables/010f12c4-0ca8-4013-9f0c-65d48538d0588, then metastore_id is `ae32f4d9-3c84-4583-9197-ffadf942bdf4dand the table ID is010f12c4-0ca8-4013-9f0c-65d48538d0588
This table ID will be preserved and will not change after every create/replace command, even if the table structure changes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-07-2025 01:11 PM
@Krishna_S thanks for your reply.
In a non UC-managed table, is it valid to see a table ID change throughout the life time of the table?
(Also, what value gives me to utilize UC to manage my tables?)