Is there a tool to generate a full database DDL for SQL Server? What about Postgres and MySQL?

后端 未结 8 1763
野性不改
野性不改 2021-02-18 22:11

Using Toad for Oracle, I can generate full DDL files describing all tables, views, source code (procedures, functions, packages), sequences, and grants of an Oracle schema. A g

相关标签:
8条回答
  • 2021-02-18 22:32

    In PostgreSQL, simply use the -s option to pg_dump. You can get it as a plain sql script (one file for the whole database) on in a custom format that you can then throw a script at to get one file per object if you want it.

    The PgAdmin tool will also show you each object's SQL dump, but I don't think there's a nice way to get them all at once from there.

    0 讨论(0)
  • 2021-02-18 22:32

    For SQL Server:

    In SQL Server Management Studio, right click on your database and choose 'Tasks' -> 'Generate Scripts'.

    You will be asked to choose which DDL objects to include in your script.

    0 讨论(0)
  • 2021-02-18 22:34

    I wrote SMOscript which does what you are asking for (referring to MSSQL Server)

    0 讨论(0)
  • 2021-02-18 22:40

    try this python-based tool: Yet another script to split PostgreSQL dumps into object files

    0 讨论(0)
  • 2021-02-18 22:44

    In addition to the "Generate Scripts" wizard in SSMS you can now use mssql-scripter which is a command line tool to generate DDL and DML scripts.

    It's an open source and Python-based tool that you can install via: pip install mssql-scripter.

    Here's an example of what you can use to script the database schema and data to a file. mssql-scripter -S localhost -d AdventureWorks -U sa --schema-and-data > ./adventureworks.sql More guidelines: https://github.com/Microsoft/sql-xplat-cli/blob/dev/doc/usage_guide.md

    And here is the link to the GitHub repository: https://github.com/Microsoft/sql-xplat-cli

    0 讨论(0)
  • 2021-02-18 22:47

    For mysql, I use mysqldump. The command is pretty simple.

    $ mysqldump [options] db_name [tables]

    $ mysqldump [options] --databases db_name1 [db_name2 db_name3...]

    $ mysqldump [options] --all-databases

    Plenty of options for this. Take a look here for a good reference.

    0 讨论(0)
提交回复
热议问题