How to export table from Netbeans, Java DB (Derby) Database

北城余情 提交于 2019-12-11 07:03:51

问题


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 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.




回答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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!