Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get table schema or structure in netbeans, derby

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?

like image 741
user2804599 Avatar asked Jan 18 '14 17:01

user2804599


1 Answers

GET TABLE STRUCTURE

select COLUMNNAME,COLUMNDATATYPE 
FROM sys.systables t, sys.syscolumns 
WHERE TABLEID = REFERENCEID and tablename = 'FRIENDS' 

enter image description here

Other fields you can use in select

  • COLUMNDEFAULT
  • COLUMNDEFAULTID
  • AUTOINCREMENTVALUE
  • AUTOINCREMENTSTART
  • AUTOINCREMENTINC

Inside Netbeans

Expand the Tables node under the sample database connection, right-click the table node and choose Grab Structure.

enter image description here

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.

enter image description here

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.

enter image description here

GET TABLES

A complete list.

select * from SYS.SYSTABLES;

enter image description here

Only TABLENAME

select TABLENAME from SYS.SYSTABLES where TABLETYPE='T'

enter image description here

Derby Table

like image 66
moskito-x Avatar answered Nov 15 '22 08:11

moskito-x