SQL Server:为什么要使用SMO?

时间:2021-10-18 07:08:10

I have been working with SQL Server for a couple of years. I have heard about SMO but I don't know anything about it. What are the benefits of using it? Should I learn and start using SMO in my SQL Server projects (mainly data warehouse development)? Why?

我已经使用SQL Server几年了。我听说过SMO,但我对此一无所知。使用它有什么好处?我应该在SQL Server项目中学习并开始使用SMO(主要是数据仓库开发)吗?为什么?

3 个解决方案

#1


5  

It depends on what you're trying to do. SMO is SQL Server Management Objects. It is a set of libraries for managing SQL Server programmatically. For example if you're trying to build a clone of SQL Maangement Studio then SMO is something you probably want to look into. OR if you're trying to manpulate the structure of your database programmatically then that's the place to look.

这取决于你想要做什么。 SMO是SQL Server管理对象。它是一组用于以编程方式管理SQL Server的库。例如,如果您正在尝试构建SQL Maangement Studio的克隆,那么您可能想要查看SMO。或者,如果您尝试以编程方式操作数据库的结构,那么这就是要查看的位置。

Otherwise, I wouldn't bother.

否则,我不会打扰。

#2


6  

From Microsoft:

来自微软:

Overview (SMO)

概述(SMO)

SQL Server Management Objects (SMO) are objects designed for programmatic management of Microsoft SQL Server. You can use SMO to build customized SQL Server management applications. Although SQL Server Management Studio is a powerful and extensive application for managing SQL Server, there might be times when you would be better served by an SMO application.

SQL Server管理对象(SMO)是为Microsoft SQL Server的编程管理而设计的对象。您可以使用SMO构建自定义的SQL Server管理应用程序。尽管SQL Server Management Studio是用于管理SQL Server的功能强大且功能强大的应用程序,但有时候SMO应用程序可以为您提供更好的服务。

For example, the user applications that control the SQL Server management tasks might have to be simplified to meet the needs of new users and to reduce training costs. You might have to create customized SQL Server databases, or create an application for creating and monitoring the efficiency of indexes. An SMO application might also be used to include third-party hardware or software seamlessly into the database management application.

例如,可能必须简化控制SQL Server管理任务的用户应用程序,以满足新用户的需求并降低培训成本。您可能必须创建自定义SQL Server数据库,或创建用于创建和监视索引效率的应用程序。 SMO应用程序还可用于将第三方硬件或软件无缝地包含到数据库管理应用程序中。

The SMO object model extends and supersedes the Distributed Management Objects (SQL-DMO) object model. Compared to SQL-DMO, SMO increases performance, control, and ease of use. Most SQL-DMO functionality is included in SMO, and there are various new classes that support new features in SQL Server. The object model is intuitive and uses SQL-DMO terminology, where it is possible, to help transfer your skills.

SMO对象模型扩展并取代分布式管理对象(SQL-DMO)对象模型。与SQL-DMO相比,SMO提高了性能,控制和易用性。大多数SQL-DMO功能都包含在SMO中,并且有各种新类支持SQL Server中的新功能。对象模型很直观,并且可以使用SQL-DMO术语来帮助转移您的技能。

You can download SMO here:

你可以在这里下载SMO:

Microsoft® SQL Server® 2008 R2 Feature Pack

Microsoft®SQLServer®2008R2功能包

And for getting started programming:

并开始编程:

Creating SMO Programs

创建SMO计划

#3


3  

I have used SMO to automatically script out object code and user permissions and add to version control.

我已经使用SMO自动编写对象代码和用户权限的脚本并添加到版本控制。

By doing this I can save privileges or object DDL as of a point in time for my auditing team or my own research or for cloning a server.

通过这样做,我可以保存特权或对象DDL作为我的审计团队或我自己的研究或克隆服务器的时间点。

I also use it so I can quickly compare object code from specific dates without needing a snapshot / backup.

我也使用它,因此我可以快速比较特定日期的目标代码,而无需快照/备份。

Recently I used SMO in a Disaster Recovery Project to script out all Server Permissions and System Database Object Permissions and run the script on the replacement server.

最近,我在灾难恢复项目中使用SMO来编写所有服务器权限和系统数据库对象权限的脚本,并在替换服务器上运行脚本。

#1


5  

It depends on what you're trying to do. SMO is SQL Server Management Objects. It is a set of libraries for managing SQL Server programmatically. For example if you're trying to build a clone of SQL Maangement Studio then SMO is something you probably want to look into. OR if you're trying to manpulate the structure of your database programmatically then that's the place to look.

这取决于你想要做什么。 SMO是SQL Server管理对象。它是一组用于以编程方式管理SQL Server的库。例如,如果您正在尝试构建SQL Maangement Studio的克隆,那么您可能想要查看SMO。或者,如果您尝试以编程方式操作数据库的结构,那么这就是要查看的位置。

Otherwise, I wouldn't bother.

否则,我不会打扰。

#2


6  

From Microsoft:

来自微软:

Overview (SMO)

概述(SMO)

SQL Server Management Objects (SMO) are objects designed for programmatic management of Microsoft SQL Server. You can use SMO to build customized SQL Server management applications. Although SQL Server Management Studio is a powerful and extensive application for managing SQL Server, there might be times when you would be better served by an SMO application.

SQL Server管理对象(SMO)是为Microsoft SQL Server的编程管理而设计的对象。您可以使用SMO构建自定义的SQL Server管理应用程序。尽管SQL Server Management Studio是用于管理SQL Server的功能强大且功能强大的应用程序,但有时候SMO应用程序可以为您提供更好的服务。

For example, the user applications that control the SQL Server management tasks might have to be simplified to meet the needs of new users and to reduce training costs. You might have to create customized SQL Server databases, or create an application for creating and monitoring the efficiency of indexes. An SMO application might also be used to include third-party hardware or software seamlessly into the database management application.

例如,可能必须简化控制SQL Server管理任务的用户应用程序,以满足新用户的需求并降低培训成本。您可能必须创建自定义SQL Server数据库,或创建用于创建和监视索引效率的应用程序。 SMO应用程序还可用于将第三方硬件或软件无缝地包含到数据库管理应用程序中。

The SMO object model extends and supersedes the Distributed Management Objects (SQL-DMO) object model. Compared to SQL-DMO, SMO increases performance, control, and ease of use. Most SQL-DMO functionality is included in SMO, and there are various new classes that support new features in SQL Server. The object model is intuitive and uses SQL-DMO terminology, where it is possible, to help transfer your skills.

SMO对象模型扩展并取代分布式管理对象(SQL-DMO)对象模型。与SQL-DMO相比,SMO提高了性能,控制和易用性。大多数SQL-DMO功能都包含在SMO中,并且有各种新类支持SQL Server中的新功能。对象模型很直观,并且可以使用SQL-DMO术语来帮助转移您的技能。

You can download SMO here:

你可以在这里下载SMO:

Microsoft® SQL Server® 2008 R2 Feature Pack

Microsoft®SQLServer®2008R2功能包

And for getting started programming:

并开始编程:

Creating SMO Programs

创建SMO计划

#3


3  

I have used SMO to automatically script out object code and user permissions and add to version control.

我已经使用SMO自动编写对象代码和用户权限的脚本并添加到版本控制。

By doing this I can save privileges or object DDL as of a point in time for my auditing team or my own research or for cloning a server.

通过这样做,我可以保存特权或对象DDL作为我的审计团队或我自己的研究或克隆服务器的时间点。

I also use it so I can quickly compare object code from specific dates without needing a snapshot / backup.

我也使用它,因此我可以快速比较特定日期的目标代码,而无需快照/备份。

Recently I used SMO in a Disaster Recovery Project to script out all Server Permissions and System Database Object Permissions and run the script on the replacement server.

最近,我在灾难恢复项目中使用SMO来编写所有服务器权限和系统数据库对象权限的脚本,并在替换服务器上运行脚本。