问题
I need to export the structure of some tables so I can easily recreate them on a different database. I tried to use the Grab Structure but this seems to work only if I try to create a new table within Netbeans. Any ideas on how to do this?
回答1:
Export a table structure
In Netbeans
right click a table to export -> Grab Structure

Save the file

- right click a table to recreate ->
Recreate Table
- open the file just created
- choose
Edit table script

- do a Ctrl-a and Ctrl-c . To mark all and copy to clipboard.
- close with
cancel
.

Important close Netbeans to close all connections ( a disconnect inside Netbeans is not enough)
Go to your Databases folder

inside this folder call your ij
otherwise the database can not be found.

connect
and select
look if the right database is opened.
- connect 'jdbc:derby:sample;user=app;password=app';
- select * from FRIENDS;

- open Notepad and paste the structure from the clipboard.
- for later use save it to file.
- here I renamed
FRIENDS
toMYFRIENDS
to not overwright myFriends
table. - Select all and copy again.
- paste to
ij
and hitenter
- do a select to test if table
MYFRIENDS
is created.

Now we close ij
with quit;
to test in Netbeans we open Netbeans again.
And here it is. everything in the right position with the right properties.

回答2:
Try using Apache DDLUtils: http://db.apache.org/ddlutils/ . It can export and import schema from many database implementations (this text added to exceed the minimum answer limit).
来源:https://stackoverflow.com/questions/28250004/how-to-export-table-from-netbeans-java-db-derby-database