The following examples demonstrate how the various dblook utility options can be specified from a command line. These examples use the sample database.
"\"My Table"\"
Status messages are written to the output (either a -o filename, if specified, or the console) as SQL script comments. These status messages serve as headers to show which types of database objects are being, or have been, processed by the dblook utility.
You can write the DDL to the console for everything that is in the sample database. In this example, the database is in the current directory. For example:
java org.apache.derby.tools.dblook -d jdbc:derby:sample
You can write error and warning messages when you write the DDL to the console. The messages are written using System.err. For example:
java org.apache.derby.tools.dblook -d jdbc:derby:sample -verbose
You can write the DDL to a file called myDB_DDL.sql for everything that is in the sample database. In this example, the database and file are in the current directory. For example:
java org.apache.derby.tools.dblook -d jdbc:derby:sample -o myDB_DDL.sql
If the database or file is not in the current directory, you must specify the directory path. For example:
java org.apache.derby.tools.dblook -d 'jdbc:derby:c:\private\stuff\sample' -o 'C:\temp\newDB.sql'
You can specify the schema for the database. To write the DDL to the console, for all of the objects in the sample database where the database is in the SAMP schema, use the following command:
java org.apache.derby.tools.dblook -d jdbc:derby:sample -z samp
If the sample database is in the SAMP schema on localhost:1527, you must specify your user ID and password. For example, use the following command to write the DDL to the console:
java org.apache.derby.tools.dblook -d 'jdbc:derby://localhost:1527/"C:\temp\sample"; user=someusername;password=somepassword' -z samp
You can specify that only the objects in the sample database that are associated with the SAMP and the My Table table are written to the console. For example:
java org.apache.derby.tools.dblook -d jdbc:derby:sample -z samp -t "My Table"
You can specify more than one table in the dblook command by separating the names of the tables with a space. For example, for objects in the sample database that are associated with either the My Table table or the STAFF table, use the following command:
java org.apache.derby.tools.dblook -d jdbc:derby:sample -t "My Table" staff
To write the DDL for all of the objects in the sample database to the myDB_DDL.sql file without a statement delimiter, you must omit the default semicolon. You can append the DDL to the output files if the files are already there. For example:
java org.apache.derby.tools.dblook -d jdbc:derby:sample -o myDB_DDL.sql -td '' -append
To write the DDL to the console for all of the objects in the sample database except for views, use the following command:
java org.apache.derby.tools.dblook -d jdbc:derby:sample -noview