drop a column from table

#1

Hi,

I want to drop one column from my database table suppose i have 3 column (id, name, address) now i want to drop address. then what will be the query or procedure..

 

#2

Just remove the field from the entity class. See Automatic Schema Evolution.

Space in the database file will be reclaimed lazily, for every entity object on its next committed change.

ObjectDB Support
#3

Hi

But it physically present and logically it will not display. If a want to drop or delete a column permanently then what will be the procedure.

#4

Because the data is physically removed only when an object is stored again, after removing the field from the entity class you will have to iterate over all the relevant objects, mark them as dirty within an active transaction (either by calling makeDirty or by setting one of their persistent fields), and of course commit the transaction.

Alternatively, you run the Doctor in repair mode to create a new database file. The schema change must be available to the Doctor, so you must open the database after the schema change in your application to register the change, or run the Doctor with a classpath that contains your entity classes.

ObjectDB Support

Reply