How to replace a table that has views reffering to it

In this thread I’m trying to repair a table:

If I can’t repair it, how can i replace it? I have and older backup copy of the database so I can copy the old ‘annual_cultivation’ table and when I paste it won’t let me because it has the same name. I can not delete it because dependent objects exist.
database file dropbox link

  1. Go to Tools → Relationships and cut off all relations from the table you want to replace to other tables. Remove the table from the relationships window.
  2. Copy the SQL-code of every view and create a query with this code. Remove every view, which needs the table you want to replace.
  3. When table has been replaced you could create the relations again. You could also create the view from the queries.

I’m creating views only from existing queries. Have written a macro for this, because there are view, which need other view. So the view will first be deleted in right order, then created new in right order from queries.

1 Like

I worked on your HSQL Version 2.3.3 database, and, with regard to the table

annual_cultivation

what I found was “id” between 3151 and 3154 were the error. ( I have no idea why ).

Therefore, I used the HSQL jar utility, sqltool.jar and able to EXPORT the data with “id” <= 3150 and “id” >= 3155.

I next used sqltool.jar in the following steps:

  1. Deleted your table ( “annual_cultivation” )
  2. Turned off all referential integrity checks
  3. Create the table at first, with “id” as an INTEGER ( NOT auto generated )
  4. Insert(ed) the data I exported above ( to keep the same “id” you had used
  5. Altered the table “annual_cultivation” to be GENERATED BY DEFAULT AS IDENTITY
  6. Turned on all referential integrity checks
  7. Proved I could see all the data in table “annual_cultivation” )

I also:

  1. Opened your .odb file with the replacement database files
  2. Tried a few Queries ( I did NOT try forms ) with “annual_cultivation” and they worked

So, see the link I am providing that contains the three files, you can download and RELACE, but, always, KEEP A BACKUP of your original files just in case:

  1. mydb.data
  2. mydb.properties
  3. mydb.script

Download the files from link here:

https://www.mediafire.com/folder/0kvaxy20sqhq2/Documents

I hope this helps, please be sure to let us know. :smile:

2 Likes

Thank you for repairing the database. I am grateful to be able to continue working on it.