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?
解决方案
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 to MYFRIENDS to not overwright my Friends table.
Select all and copy again.
paste to ij and hit enter
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.