Login | Register
My pages Projects Community openCollabNet

tedia2sql Brief Help

tedia2sqlrc file

Some of these options can be specified in a $HOME/.tedia2sqlrc file (or, optionally, "tedia2sqlrc" stored in the same path as the tedia2sql executable).

Commandline arguments always override preferences specified in the rcfile.

-h: The Barebones Help

When you run tedia2sql with the -h commandline switch, you will get a short help that looks like the following.

tedia2sql -- vX.YY.ZZ Copyright (c)2002 by Tim Ellis <tim[dot]ellis[at]gamet[dot]com>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2. This program is copyrighted!

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Usage: tedia2sql [-t dbType] [-v {1 | 2}]
    [-s] [-d] [-u] [-h]
    [-i xmlIn] -o sqlOut [files...]

-t dbTypeType of database to gen SQL for (informix, ingres, postgres, mysql, mssql, sybase, oracle, db2)
-c Print less comments in output (useful for version control comparisons);
-s Separate constraint drops, constraints, table drops, tables into separate SQL output files
-d Add 'drop' syntax to SQL output file
-u Use UML interpretation of the diagram rather than the default ERD interpretation
-C Use case of names in name comparisons, even if the database ignores case
-p names:types Automatically generate primary keys whan needed with name and type given
-f Automatically generate foreign keys in tables when needed
-b Backwards-compatibility - generate SQL more like tedia2sql v1.2.9b
-k Write/keep output files even if there is an error
-m Produce warnings, not fatal errors where foreign key and primary keys don't have same type
-M Don't test types of foreign keys against their primary key types
-v {1 | 2} Verbosity level, 1=verbose, 2=very verbose
-h This help, copyright, and licensing information
-i xmlIn XML File to parse, should be created by Dia
-o sqlOutName of output -- don't give extension, .sql will be appended
files...More input files - at least one input file must be specified

vX.YY.ZZ -- Version

The version of tedia2sql you are running. The X means the major revision. If tedia2sql is completely rewritten or uses a new set of libraries to achieve its goals, the X will be incremented by one. If YY is ODD, then you are using a development (unstable or untested) version of the script. If it is EVEN, you are using a stable, tested version.

Copyright and License

This script is not public domain. It is a copyrighted script licensed under the GNU GPL version 2. Note specifically this slightly varies from the standard method of licensing GPL scripts in that you cannot use a later version of the GPL at your discretion. This is licensed as version 2 of the GPL, the text of which is included in the file LICENSE which is distributed with tedia2sql.

-t: Database SQL DDL Type

tedia2sql supports multiple databases. To select which database to output for, pass one of the following on the commandline:
  • -t db2 -- IBM's DB/2 v7 or greater
  • -t mssql -- Microsoft's SQL Server
  • -t mysql -- MySQL
  • -t oracle -- Oracle v8i or greater
  • -t postgres -- PostgreSQL (Postgres) 7.2 or greater
  • -t sybase -- Sybase ASE v11.0.3.3 or greater
  • -t informix -- IBM's Informix
  • -t ingres -- Ingres
  • -t sas -- SAS

-s: Separate the Add, Drop, Constraint, and Table Scripts

When you specify the -s option, there will be multiple files created (four if you pass the -d option, two if you don't) to specify adds, drops, constraints, and table names in separate files. Each file will be prefixed with the word you pass to the -o option, and will have an extension of the extension you pass to the -o option.

Each SQL script generated will have a "1st" "2nd"... etc in the filename so that when sorted ASCIIbetically, a parent script will know in which order to run the SQL scripts. Also, if you look at the filenames, you will know in which order to run the scripts.

If you do not pass the -s option, then you will only ever get one file with all statements in the order tedia2sql thinks is best:

  1. Drop constraints
  2. Drop tables
  3. Create tables
  4. Insert data
  5. Create constraints and indexes
Because the script doesn't have any intelligence about the order in which it creates the INSERT statements (ie: fulfill foreign-key constraints), it must create the constraints after it inserts the data. If you don't like this idea (ie: you're using constraints to make sure your data is correct), then you can pass the -s option and run the scripts in the order you choose.

-d: Create drop statements

If you want to drop each constraint and table before you create them, pass this option to the script. Note that if you also pass -s that the drop statements will appear in their own SQL DDL file.

-u: Interpret as UML

Interpret the diagram as a UML diagram, rather than as an ERD diagram using UML symbology. In the default (ERD) mode, many-to-one associations are written using the UML aggregation notation, with the aggregation diamond mark on the 'many' end of the association. With the -u option, the UML convention is followed where the diamond aggregation or composition marker is on the 'one' end of the association.

-p names:types : Automatically generate primary keys

Where a reference is made to a primary key, and the key does not exist, generate a key with the given names and types. The default primary key can be multi-part, in which case names and types are comma-separated lists of the primary key names and types; the lists must be the same length. E.g: -p 'key1, key2: int, int'. White space is ignored.

-f: Automatically generate foreign keys

Where a reference is made to a foreign key, and the key does not exist, generate a key from the corresponding primary key's names and types. If there is no role determining the name of the foreign key, the key name is generated using the normal rules.

-b: Backwards compatibility

tedia2sql v1.2.10 makes some changes in the rules for generating private key constraint names and some minor formatting chamges. The -b option makes v1.2.10 generate SQL that is more like that from v1.2.9. For -t oracle, it is necessary to do diff -b to ignore whitespace changes when comparing SQL generated by v1.2.10 with SQL generated by v1.2.9, because v1.2.10 for Oracle allows the use of on delete clauses, and that generates an extra space character in each foreign key constraint definition.

This option is only intended for use in simplifing the verification of SQL generated by v1.2.10 against SQL generated by v1.2.9.

-m: Only warn on type mismatches

Normally, tedia2sql generates a fatal error if there are any type mismatches between foreign keys and their corresponding primary keys. This is done on the basis of the text form of the type, and ignores possible type equivalences in the database. The -m option produces the same warning messages, but permits generation of SQL even if there are type mismatches. Should be used with some caution.

-M: Ignore type mismatches

As for -M but disables foreign key/primary key typechecking altogether. Use with caution.

-v: Verbosity Level

If you would like to see what the script is doing while it runs via printing to STDOUT, then pass -v 1. Sometimes, if the script is malfunctioning, then a developer might ask you to run the script with -v 2 which will put even more debugging output to STDOUT. You will probably not be interested in either of these options unless you plan on changing the tedia2sql script.

-i: Input File

The input file must be a Dia UML diagram created by Dia version 0.90 or greater. tedia2sql detects if the file is compressed with gzip or not.

-o: Output File Format

tedia2sql will parse the filename you pass it for a BASE (what appears before the final dot) and extension (what appears after the final dot) and will generate output files accordingly. You should just pass to -o what you feel is intuitive, and it should do the right thing. If you pass the -s commandline option, you will get more than one SQL DDL file. See the section on -s.


tedia2sql allows its input file names to be specified either with the -i option, or by giving a list of filenames following the options. Multiple -i options may be given, but only the last of them is used (and no warning is given -- this is a feature(?) of the perl Getopt::Std package). If you want to use multiple files, list them after the options.

At least one input file must be named.

If both -i and the file list are used to name input files, the last file indicated by -i is processed, followed by the files in the file name list. Processing order in the files may change the order that SQL statements are produced, but it should not affect the function of the SQL.