Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate table DDL via query on MySQL and SQL Server

People also ask

How do I create a DDL script in MySQL?

You can create a data definition (DDL) script by executing the mysqldump db_name --no-data > script_file. sql command. Using the --no-data option ensures that the script contains only DDL statements.

How do I create a DDL script in SQL?

You need to Right click on the Database in which the objects exists. Then go to Tasks and hit Generate Scripts. In Next window, you will be able to choose the objects for which you would like to create script.


it's mysql-specific, but SHOW CREATE TABLE <table-name> gives you the DDL for a table.


You have to create that yourself.

You can query INFORMATION_SCHEMA.COLUMNS for the column name and data type.


You can't get the CREATE Table text in a cross platform way, but you can get enough information to build it yourself from the INFORMATION_SCHEMA views.