Skip to Content

generate ALL db's DDL in a ASE server

Hi List,

I am looking for a solution to generate a script : DDL's for all user databases from a ASE 16.0 ( only db's creation, not other objects), I used: ddlgen -TDB -N% -o db's.sql but this will get all system db's from a server also , and objects def, is there a more elaborate option with ddlgen ?

Thank you

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Jan 18, 2017 at 08:36 PM

    Unfortunately there is (currently) no way to automagically determine which databases are 'system' dbs and which are 'non-system' dbs (eg, there is no this-is-a-system-database flag in sysdatabases).

    Your best bet is to generate your own list of db names and then run ddlgen against said list of databases.

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 18, 2017 at 09:00 PM

    Mark , thank you for comment.

    How do I exclude the db's objects DDL with DDLGEN ?

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 18, 2017 at 09:18 PM

    Try filtering out all object types, eg:

    ddlgen -U<login> -P<password> -S<server_name> -N<dbname> -F%

    You could then filter the output through egrep/sed/awk (take your pick) to discard stuff like use <dbname>, sp_dboption, sp_changedbowner, etc.

    Altenatively you could write your own SQL script to generate the create/alter database commands from a join of sysdatabases/sysusages/sysdevices.

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 19, 2017 at 03:17 PM

    FWIW, here's a thread from mid-2016 discussing ideas on how to distinguish 'system' dbs from user dbs: https://archive.sap.com/discussions/thread/3912153

    Add comment
    10|10000 characters needed characters exceeded