sqldef.pl - Convert RDBMS schema to mSQL DDL
sqldef.pl [ --catalog-only ] [ --no-sequences ] [ --help ]
sqldef.pl will read a text-based schema for a relational database on standard input and generate the corresponding Data Definition Language (DDL) on standard output to create an mSQL 2.x database.
Most commonly you would pipe the output of sqldef.pl to the msql monitor program (this will wipe out all of the data in the specified database):
sqldef.pl db.schema | msql db
Table and column definitions consist of lists of colon seperated fields.
Where an optional parameters is omitted the corresponding field should be left blank.
All lines beginning with # are comments.
name of the table
table description (used in various HTML pages)
HTML file to use when viewing the file as a result of a query
name of the column
data type of the column. This can be set to any one of the standard mSQL types int|char|text|date or the `pseudo types' datetime|created|modified|boolean.
the width of a char or text column
additional mSQL constraints on the column e.g. not null.
short description of the table (used in various HTML pages)
list of key types seperated by +. Valid key types are
for a primary key
for a foreign key
for a column to be used in a selection list to identify a row from a related table
if one of the key types is FOREIGN, the name of the related table
if one of the key types is FOREIGN, the name of the related column in fkey_table
type of link: MAILTO, URL or IMG
non-zero to prompt for this column in queries
non-zero to display this column in query results
name of column to use as label of link
# company.schema # company table table:company:companies:: cmpny_id:int::not null:Unique Id:PRIMARY::::0:0: cmpny_name:char:40::Company name:LABEL::::1:1: # product table table:product:goods/services:: prod_id:int::not null:Unique Id:PRIMARY::::0:0: prod_name:char:40::Product/services:LABEL::::1:1: # supply table # M:N (company:product) table:supply:supply of goods/services:: supply_cmpny:int:::Company:PRIMARY+FOREIGN+LABEL:company:cmpny_id::1:1: supply_prod:int:::Product:PRIMARY+FOREIGN+LABEL:product:prod_id::1:1:
--catalog-only only create DDL for system catalog
--no-sequences don't create DDL for table sequences
Useful if you plan to dump your data with a program like msqldump, change the schema and then reload the data, as it will preserve your table sequences.
--help print a usage messages, then exit
Brian Jepson <bjepson@conan.ids.net>
Paul Sharpe <paul@miraclefish.com>
You may distribute this under the same terms as Perl itself.
To install Msql::RDBMS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Msql::RDBMS
CPAN shell
perl -MCPAN -e shell install Msql::RDBMS
For more information on module installation, please visit the detailed CPAN module installation guide.