简体   繁体   English

创建sql服务器数据库作为其他sql数据库结构(设计)

[英]create sql server database as other sql database structure (design)

I need to create sql database just like other sql database (without the data) via sql script 我需要通过sql脚本创建sql数据库,就像创建其他sql数据库一样(没有数据)

some one told me that Oracle has this ability by some code like 有人告诉我,Oracle通过以下代码具有这种能力

create database <your new DB name> as <the old DB name>

so is there a similar statement or workaround in SQL 所以在SQL中是否有类似的语句或解决方法

I use MS-SQL Server 2008/2008R2 我使用MS-SQL Server 2008 / 2008R2

I don't want the 'generate scrip' solution as this provide a very long script, I just need the Oracle statement (mentioned above) but in SQL 我不想使用“生成脚本”解决方案,因为它提供了很长的脚本,我只需要Oracle语句(如上所述),但是在SQL中

to be more clear I need the tables structure only (no data) and need all other objects such as functions, views etc... 更清楚地说,我只需要表结构(没有数据),并且需要所有其他对象,例如函数,视图等。

Please advice, 请指教,

If you are asking about SQL Server (at least in 2005 or newer, not sure about previous versions) if you right click on a Database in SQL Server Management Studio Go To Tasks and then Generate Scripts you have the option to Generate a script to create all the object ins the Database w/o Data. 如果您询问有关SQL Server的信息(至少在2005年或更晚的版本中,不确定以前的版本),是否在SQL Server Management Studio中右键单击“数据库”,然后单击“转到任务”,然后选择“生成脚本”,则可以选择“生成脚本来创建”所有对象都在没有数据的数据库中。

Update: You can also right click on a User Database and select Script Database as -> Create To just to get the TSQL to create the DB itself without any of the tables, stored procedure etc. 更新:您也可以右键单击用户数据库,然后选择“脚本数据库”-->“创建到”,只是为了让TSQL创建没有任何表,存储过程等的数据库本身。

在SQL Server中,可以右键单击数据库,然后选择“任务”,然后选择“生成脚本”,然后可以为所有对象(不含数据)构建一个脚本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM