SQL Server架构创建f或现有数据库 [英] SQL Server Schema creation f or existing database

查看:94
本文介绍了SQL Server架构创建f或现有数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我创建了一个数据库,所有对象都像表存储过程和用户​​定义的表类型在默认模式(dbo)下。



现在我想创建一个新的模式并将我的所有存储过程映射到新模式。

因此对表的所有更改只能通过存储发生程序,并避免在我的桌子上直接DML。也将此架构映射到[NT AUTHORITY \ NETWORK SERVICE]用户角色。



提前谢谢。

解决方案

创建新模式

脚本创建SSMS查询的所有过程

在dbo上搜索并替换替换它新架构

运行脚本



你现在应该有2份所有程序




您可以像这样使用查询...

<前lang =SQL> ALTER SCHEMA 目的地< span class =code-keyword> schema TRASFER Object :: current schema .TableName;
对于示例: ALTER SCHEMA dbo TRANSFER HWData.DesktopSoft_Master;



检查以下链接...

脚本将所有对象移动到SQL Server的新架构 [< a href =http://www.mssqltips.com/sqlservertip/2474/script-to-move-all-objects-to-a-new-schema-for-sql-server/target =_ blanktitle = 新窗口> ^ ]

如何更改SQL Server 2008/2005对象架构? [ ^ ]

问候,

GVPrabu


Hi,

I have created a database and all object like tables stored procedure and user defined table type under a default schema (dbo).

Now i want to create a new schema and to map all my stored procedure to New schema.
So that all changes to the table happens only through stored procedure and to avoid direct DML on my table.Also to map this schema to [NT AUTHORITY\NETWORK SERVICE] user role.

Thanks in advance.

解决方案

Create the new schema
Script all the procedures create to SSMS query
Search and replace on dbo replacing it with the new schema
run the script

You should now have 2 copies of all the procedures


Hi
You can use Query like this...

ALTER SCHEMA the destination schema TRASFER Object::current schema.TableName;
For Example : ALTER SCHEMA dbo TRANSFER HWData.DesktopSoft_Master;


Check the following links...
Script to move all objects to a new schema for SQL Server[^]
How To Change SQL Server 2008/2005 Object Schema?[^]
Regards,
GVPrabu


这篇关于SQL Server架构创建f或现有数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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