Skip to content

Remove and Restore a table

feiben edited this page Dec 13, 2016 · 4 revisions

Every table created will be loaded when db starts, and has its own memory and storage cost. In the case that a table is discarded, or replaced by a new designed version, you may want to remove it from the whole list, release its memory but not to delete its data from storage since it may be in future use.

LunarBase exposes two APIs to REMOVE and RESTORE a table.
#Remove

LunarDB l_db = LunarDB.getInstant();
String table_to_be_removed = "test_table";  

l_db.removeTable(table_to_be_removed );

After calling this, "test_table" will be closed immediately, all its memory will be released, and it becomes invisible to any other db APIs.

When database restarts, this table will not be loaded. Nothing can be inserted into, updated, or retrieved from this table.

#Remove

LunarDB l_db = LunarDB.getInstant();
String table_is_removed = "test_table";  

l_db.restoreTable(table_is_removed);

Then "test_table" works again. You may remember what the table name is when you try to restore it.

Clone this wiki locally