codenotary / immudb

immudb - immutable database based on zero trust, SQL/Key-Value/Document model, tamperproof, data change history
https://immudb.io
Other
8.62k stars 343 forks source link

ALTER TABLE #968

Closed titouancreach closed 3 years ago

titouancreach commented 3 years ago

Hello,

This is more a question than a feature request, but I don't know how to alter a table (is it possible ?). I forget a column when I created the table. My table contains data so I cannot drop it / recreate it. Do we have any solution here ? (I cannot find anything in the SQL reference (https://docs.immudb.io/master/reference/sql.html)

Thanks

What would you like to be added or enhanced

Why is this needed

Additional context

it looks like it's not supported yet: https://github.com/codenotary/immudb/blob/0ce8853ee9bf09ed288b4c370db3ac28f3cab9a7/embedded/sql/engine_test.go#L248

byo commented 3 years ago

Hi @titouancreach, currently immudb does not support altering tables. However we have plans to allow at least simple ALTER TABLE statements like the one you need (adding column, renaming etc).

What version of immudb are you using? Is the data critical and used n production?

Currently the three workarounds that could be used here are:

  1. create new table will all necessary changes and copy data to it - the old data would of course be duplicated that way and will occupy disk space
  2. create new table with only the missing columns and the same primary key and use joins - no extra disk space requirement but it will use more complex queries with joins and will be a bit slower
  3. create new DB from scratch and migrate data from the old DB to the new one - but here we're loosing all the verification properties so merkle proofs will have to be restarted etc.
titouancreach commented 3 years ago

Hello @byo

However we have plans to allow at least simple ALTER TABLE statements like the one you need (adding column, renaming etc). ❤️

I use the latest version I think (the latest docker image) immudb: v1.1.0 (git fd772C1).

I will definitively use the first option since the option 2 will make the complexity grow, and I use immudb for the data verification 🙂

Thanks for your fast answer.