ddlgen in Sybase
Posted by: Colin Smith
I completed an upgrade from Sybase 12.5 to Sybase 15.0 recently and I found that it ended up breaking some scripts that we use to generate ddl for all instance devices and all create databases. The scripts that we were using were writting log ago by people that are no longer working for the company. I decided to change this up to use ddlgen to create all this for us. ddlgen is a very nice little program that is able to generate the ddl and output it into files for use, if needed, in the future. Here is what I did to get all the devices ddl out of an instance.
ddlgen -U username -S servername -TDBD -N% -O outputfilename
That is simple enough to do and man it works great. This will get you the DDL needed to init all of the devices on the instance. Now I need to get the DDL to create all of the databases. For this I wrote a little shell script to get a listing of all the databases and then do the ddl gen for each. Here is that.
#!/bin/ksh
dblist=`isql -S servername -Usa << endit | tail +4
password
use master
go
set nocount on
go
select name
from sysdatabases
go
exit
endit
`
echo $dblist
for db in $dblist
do
ddlgen -Usa -SCIRC_DBA -D $db -TDB -F% -O $db.definitions.out
password
done




