Reputation: 97
I've been creating a database in derby/netbeans. And I'd like to output the structure of the database, not just exporting the whole database. How do I do this?
I've tried both "EXEC 'table name';" which returned "Error code -1, SQL state 42X01: Syntax error: Encountered "exec" at line 1, column 1." and "SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = 'table name';" which returned "Error code -1, SQL state 42Y07: Schema 'INFORMATION_SCHEMA' does not exist".
I've read on multiple forums that this should work, do you guys have any idea what I'm doing wrong?
Upvotes: 5
Views: 15303
Reputation: 2917
The simplest with NetBeans (8.0, perhaps with the previous versions too): "View Data..." of the table, right click on the data and choose "Show SQL Script for CREATE". You can copy the SQL script.
Upvotes: 2
Reputation: 16389
Another way to do this is to use the "dblook" utility: http://db.apache.org/derby/docs/10.10/getstart/tgsrunningdblook.html
Upvotes: 0
Reputation: 11968
GET TABLE STRUCTURE
select COLUMNNAME,COLUMNDATATYPE
FROM sys.systables t, sys.syscolumns
WHERE TABLEID = REFERENCEID and tablename = 'FRIENDS'
Other fields you can use in select
Inside Netbeans
Expand the Tables node under the sample database connection, right-click the table node and choose Grab Structure.
In the Grab Table dialog that opens, specify a location on your computer to save the grab file that will be created. Click Save.
The grab file records the table definition of the selected table. Expand the APP schema node under the Contact DB database connection, right-click the Tables node and choose Recreate Table to open the Recreate Table dialog box.
In the Recreate Table dialog box, navigate to the location where you saved the CUSTOMER grab file and click Open to open the Name the Table dialog box.
GET TABLES
A complete list.
select * from SYS.SYSTABLES;
Only TABLENAME
select TABLENAME from SYS.SYSTABLES where TABLETYPE='T'
Upvotes: 6