本文介绍了MS SQL 2008 - 创建没有数据的数据库副本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在MS SQL Server 2008 R2中,如何根据旧数据库的模式创建新数据库,但不复制任何数据?我正在使用SQL Server管理工作室。
In MS SQL Server 2008 R2, how do I create a new database based on the schema of the old one, but without copying any of the data along with it? I am using SQL Server management studio.
推荐答案右键单击数据库并选择任务 - > 生成脚本。
Right click the Database and select Tasks -> Generate Scripts.
然后,您可以选择所需的所有对象或仅选择某些对象。
You can you then select all the objects you require or only certain objects.
您应该看一些脚本选项:
There are some Script Options that you should look at:
- 脚本USE DATABASE - 如果要创建具有不同名称的新数据库,则应将其设置为false。
- 索引&触发器不是默认脚本
- 登录&对象级权限不作为默认脚本编写
- 为从属对象生成脚本 - 默认情况下设置为false,但您可能希望将其更改为true以确保所有对象都已编写脚本。 / li>
- Script USE DATABASE - You should set this to false if you are creating a new database with a different name.
- Indexes & Triggers are not scripted as default
- Logins & Object Level Permissions are not scripted as default
- Generate Script for Dependent objects - this is set to false as default but you may want to change it to true to ensure that all objects are scripted.
您可以将它们创建到新的查询窗口或将它们保存到SQL文件。
You can either create these to a new Query Window or save them to SQL Files.
更多推荐
MS SQL 2008
发布评论