jDbSync jDBSync
Additinal Tasks

SourceForge.net Logo

ExportStruct task

Export table or view structure in a file as SQL

Java class is org.chur.ant.db.dbstructure.ExportStructTask

Parameters

Attribute nameDescriptionRequiredDefault
driverClass name of the jdbc driverYes – 
urlDatabase connection urlYes – 
useridDatabase user nameYes – 
passwordDatabase passwordYes – 
profile DB profile which will be used to prepare SQL. If value is not present then DB profile will be detected according to <url> attribute. Out-of-box are supported the following profiles: If DB type cannot be identified "common" profile is used. Nodepends on url
profileClass Class name which should implement DB profile (org.chur.ant.db.profiles.DBProfile). If specified "profile" attribute this value will be ignored. No – 
schema Schema name to inspect No current userid schema
out Output file for inspection results No System.out

Parameters specified as nested elements

table

Use nested <table> elements to specify which tables structure should be discovered. To get more details about this task see this page.

view

Use nested <view> elements to extract SQL definition of a view. This is database specific task and currently only DB2 and Oracle are supported. To get more details about this task see this page.

At least one <table> or <view> element should be specified.

Examples

<taskdef name="ExportStruct" classname="org.chur.ant.db.dbstructure.ExportStructTask"/>
<ExportStruct
	driver="oracle.jdbc.OracleDriver"
	url="jdbc:oracle:thin:@tiger:1521:tigerdb"
	userid="system"
	password="manager"
	dest="export1.sql">
		<table taskName="DUAL"/>
</ExportStruct>
			

This task discovers the structure of DUAL table and saves SQL to re-create the table in export1.sql file:

-- Primary key:
CREATE TABLE DUAL (
DUMMY VARCHAR2(1));
			
<taskdef name="ExportStruct" classname="org.chur.ant.db.dbstructure.ExportStructTask"/>
<ExportStruct
	driver="oracle.jdbc.OracleDriver"
	url="jdbc:oracle:thin:@tiger:1521:tigerdb"
	userid="system"
	password="manager"
	schema="SYS"
	dest="export2.sql">
		<view taskName="ALL_ALL_TABLES"/>
</ExportStruct>
			

This task discovers the SQL which has been used to create ALL_ALL_TABLES view and saves this SQL in export2.sql file:

select OWNER, TABLE_NAME, TABLESPACE_NAME, CLUSTER_NAME, IOT_NAME, STATUS,
	PCT_FREE, PCT_USED,
.....
	CLUSTER_OWNER, DEPENDENCIES, COMPRESSION, DROPPED
from all_tables
union all
select OWNER, TABLE_NAME, TABLESPACE_NAME, CLUSTER_NAME, IOT_NAME, STATUS,
	 PCT_FREE, PCT_USED,
....
 	CLUSTER_OWNER, DEPENDENCIES, COMPRESSION, DROPPED
from all_object_tables