oracreate – Printing a schema definition
Purpose
oracreate prints the SQL of all objects in an Oracle database schema in a way that can be used to recreate the schema (i.e. objects will be ordered so that no errors happen for nonexistent objects during script execution). oracreate can also be used to actually recreate the schema.
Options
oracreate supports the following options:
- -v, --verbose
Produces output (on stderr) while the database is read or written. (Allowed values are
false
,no
,0
,true
,yes
or1
)
- -c <mode>, --color <mode>
Should the output (when the
-v
option is used) be colored? Ifauto
is specified (the default) then the output is colored if stderr is a terminal. Valid modes areyes
,no
orauto
.
- -s <flag>, --seqcopy <flag>
Outputs
CREATE SEQUENCE
statements for the existing sequences that have the current value of the sequence as the starting value (otherwise the sequences will restart with their initial value). (Valid flag values arefalse
,no
,0
,true
,yes
or1
)
- -x <connectstring>, --execute <connectstring>
When the
-x
argument is given the SQL script isn’t printed on stdout but executed in the database specfied as the-x
argument.
- -k <flag>, --keepjunk <flag>
If false (the default), database objects that have
$
orSYS_EXPORT_SCHEMA_
in their name will be skipped (otherwise these objects will be included). (Valid flag values arefalse
,no
,0
,true
,yes
or1
)
- -i <flag>, --ignore <flag>
If true, any exception that occurs while the database is read or written will be ignored. (Valid flag values are
false
,no
,0
,true
,yes
or1
)
- --format <format>
If
--execute
is not given, this determines the output format: Plain SQL (formatsql
), or PySQL (formatpysql
) which can be piped intoll.pysql
.
Examples
Print the content of the database schema user@db
:
$ oracreate user/pwd@db >db.sql
Copy the database schema user@db
to user2@db2
:
$ oracreate user/pwd@db -x user2/pwd2@db2 -v