| View previous topic :: View next topic |
| Author |
Message |
swidler General User

Joined: 09 Mar 2011 Posts: 9
|
Posted: Wed Feb 15, 2012 12:14 am Post subject: copying database structure [solved] |
|
|
i have a database that i want to update with new data. is there a way to create a new db file with all of the structure (including forms and queries) of an old one, but none of the data?
Last edited by swidler on Sun Feb 19, 2012 11:52 am; edited 1 time in total |
|
| Back to top |
|
 |
Arineckaig OOo Advocate

Joined: 01 Mar 2004 Posts: 331
|
Posted: Wed Feb 15, 2012 12:40 am Post subject: |
|
|
Make a copy of the .odb file and in the copy delete all the data in the tables or even the tables themselves. _________________ When this issue has been resolved, it helps other users of the forum if you add the word [Solved] to the Subject line of your 1st post (edit button top right).
OOo 3.4.1 and MySQL on MS Windows XP and Ubuntu |
|
| Back to top |
|
 |
mgroenescheij Super User

Joined: 20 Apr 2011 Posts: 862 Location: Australia
|
Posted: Wed Feb 15, 2012 12:42 am Post subject: |
|
|
Do you use the embedded database or an external database?
Which database? _________________ If your problem has been solved please add "[Solved]" to the beginning of your first post title (edit button). |
|
| Back to top |
|
 |
swidler General User

Joined: 09 Mar 2011 Posts: 9
|
Posted: Wed Feb 15, 2012 12:54 am Post subject: |
|
|
arinekaig--correct me if i'm wrong, but doesn't this screw up the (autoincrement) numbering? i have a vague recollection that once a number is in there, even if the record is erased, the next record uses the next number.
mgroenscheij--what do you mean? it's a simple database, built (or perhaps rebuilt) in base. (originally, i used access, and then i switched over.) |
|
| Back to top |
|
 |
Arineckaig OOo Advocate

Joined: 01 Mar 2004 Posts: 331
|
Posted: Wed Feb 15, 2012 1:29 am Post subject: |
|
|
If it is critical that the auto-increment numbering of the clean table should re-start at 0, 1 or whatever there are two potential remedies. The first has general application, the second is often easier to implement but can be tedious.
Either, use Tools>SQL to execute the direct SQL statement:
| Code: | | ALTER TABLE table ALTER COLUMN column RESTART WITH value |
For example:
Code:
| Code: | | ALTER TABLE "contacts" ALTER COLUMN "id" RESTART WITH 0 | .
Alternatively, do not delete initially delate data or the tables in the new .odb file, but in in its table fram copy and paste each table BUT each time in the 'Copy table' dialog make sure the 'Definition' radio button is selected. This creates new empty tables and in each case the auto-increment field should revert to 0. Wherever it does not, simply leave that field out from the field transfer dialog and let Base add its own auto primary key. Only after the new tables have been created can you delete the old and rename the new. |
|
| Back to top |
|
 |
swidler General User

Joined: 09 Mar 2011 Posts: 9
|
Posted: Wed Feb 15, 2012 1:34 am Post subject: |
|
|
| since there are only 3 tables, the first one looks great. hope it works. thanks for the help. btw--am i crazy for thinking there should be a built-in function that copies a db's structure? |
|
| Back to top |
|
 |
mgroenescheij Super User

Joined: 20 Apr 2011 Posts: 862 Location: Australia
|
Posted: Wed Feb 15, 2012 3:04 am Post subject: |
|
|
Hi,
| swidler wrote: | | mgroenscheij--what do you mean? | What I meant is that with an embedded database (the one that's come with OpenOffice) you can solve it the way Arineckaig described, if it is an external database e.g. MySQL you need an other solution.
Embedded database:
When you copy the odb file you have two base files with each their own database.
External database:
When you copy the odb file you have two base front-ends pointing to the same database.
When you update/delete records from one of the base front-ends, you will see these updates in the other front-end.
Martin _________________ If your problem has been solved please add "[Solved]" to the beginning of your first post title (edit button). |
|
| Back to top |
|
 |
swidler General User

Joined: 09 Mar 2011 Posts: 9
|
Posted: Sun Feb 19, 2012 11:51 am Post subject: |
|
|
| thanks everyone--this worked fine. |
|
| Back to top |
|
 |
|