编写SQL Server数据库对象脚本的方法

In this article, we will explore various ways for scripting SQL Server database objects.

在本文中,我们将探索编写SQL Server数据库对象脚本的各种方法。

介绍 (Introduction)

DBAs and developers manage environments for a SQL database. While managing multiple copies, sometimes we require the following tasks.

DBA和开发人员管理SQL数据库的环境。 在管理多个副本时,有时我们需要执行以下任务。

  1. Database refresh from a production environment to the lower environments. It requires copying all database objects such as database schema, tables, stored procedures, functions, indexes. We use multiple approaches such as database backup restore, object scripts, BACPAC method depending upon the requirement

    数据库从生产环境刷新到较低环境。 它需要复制所有数据库对象,例如数据库架构,表,存储过程,函数,索引。 我们根据需要使用多种方法,例如数据库备份还原,对象脚本,BACPAC方法
  2. Sometimes, we do not require data and have the requirement to export and import all objects in a destination database

    有时,我们不需要数据,而是需要导出和导入目标数据库中的所有对象

In this article, we will explore different ways to export database objects without data.

在本文中,我们将探索不使用数据导出数据库对象的不同方法。

为SQL数据库生成脚本向导 (Generate Scripts Wizard for SQL Database)

We can use Generate Scripts wizard for scripts of all database objects or specific objects. It provides various configuration options to choose from.

我们可以使用“ 生成脚本”向导生成所有数据库对象或特定对象的脚本。 它提供了多种配置选项供您选择。

Right-click on the source SQL database for which you want to generate script and launch Generate scripts wizard as shown below.

右键单击要为其生成脚本的源SQL数据库,然后启动“生成脚本”向导,如下所示。

Generate Scripts Wizard

It launches generate scripts wizard with a brief introduction and high-level steps.

它启动带有简要介绍和高级步骤的生成脚本向导。

  • Select database objects

    选择数据库对象
  • Specify scripting options

    指定脚本选项
  • Review your selections

    查看您的选择
  • Generate script and save them

    生成脚本并保存

Generate Scripts Wizard for database objects

In the next step, we get options to script an entire database or select specific objects from the following list.

在下一步中,我们将获得用于编写整个数据库脚本或从以下列表中选择特定对象的选项。

  • Tables

    桌子
  • Views

    观看次数
  • Stored procedure

    存储过程
  • User-defined functions

    用户定义的功能
  • User-defined data types

    用户定义的数据类型
  • DDL triggers

    DDL触发器
  • XML schema collections

    XML模式集合
  • Schemas

    模式
  • Full-text catalogs

    全文目录

Select objects

Let’s select

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值