SQL脚本的SQL Server命令行工具(2)

# generate DDL scripts for all objects in the Adventureworks database and save the script to a file mssql-scripter -S localhost -d AdventureWorks -U sa # alternatively, specify the schema only flag to generate DDL scripts for all objects in the Adventureworks database and save the script to a file mssql-scripter -S localhost -d AdventureWorks -U sa --schema-only

Dump database object data

# generate DDL scripts for all objects in the Adventureworks database and save the script to a file mssql-scripter -S localhost -d AdventureWorks -U sa --data-only

Dump the database object schema and data

# script the database schema and data to a file. mssql-scripter -S localhost -d AdventureWorks -U sa --schema-and-data > ./adventureworks.sql # execute the generated above script with sqlcmd sqlcmd -S mytestserver -U sa -i ./adventureworks.sql

Include database objects

# generate DDL scripts for objects that contain 'Employee' in their name to stdout mssql-scripter -S localhost -d AdventureWorks -U sa --include-objects Employee # generate DDL scripts for the dbo schema and pipe the output to a file mssql-scripter -S localhost -d AdventureWorks -U sa --include-objects dbo. > ./dboschema.sql

Exclude database objects

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/92fb261442e6ea0044d16bd18735a734.html