从具有所有对象的现有数据库动态创建新数据库 [英] create new database from existing database with all objects dynamically

查看:124
本文介绍了从具有所有对象的现有数据库动态创建新数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从现有数据库创建新数据库,该数据库应仅包括架构而不包括数据,还应包括存储过程,函数,触发器,表,视图,约束和所有其他数据库对象之类的所有对象.

How to create new database from existing database which should include only schema but not data and also all Objects like Stored Procedure, Functions, Triggers, Tables, Views, Constraints and All Other Database Objects.

推荐答案

备份数据库
创建新数据库,将备份还原到新创建的数据库中

在sqlserver编辑器中运行以下查询,复制查询的输出
打开新的查询"窗口,粘贴输出并运行(F5),这将截断所有表数据

Take back up of database
create new database, restore the backup in your newly created database

run the below query in sqlserver editor copy the output of the query
open new Query window paste the output and run(F5), this will truncate all the table data

select 'truncate table ' + TABLE_NAME  from INFORMATION_SCHEMA.TABLES  where TABLE_TYPE like 'BASE TABLE'


这篇关于从具有所有对象的现有数据库动态创建新数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆