Skip to content

Latest commit

 

History

History
38 lines (26 loc) · 2.02 KB

creating-altering-and-removing-database-objects.md

File metadata and controls

38 lines (26 loc) · 2.02 KB
title description author ms.author ms.date ms.service ms.topic helpviewer_keywords monikerRange
Working with Database Objects
Creating, Altering, and Removing Database Objects
markingmyname
maghan
03/14/2017
sql
reference
database objects [SMO]
objects [SMO]
=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-mi-current

Creating, Altering, and Removing Database Objects

[!INCLUDE SQL Server ASDB, ASDBMI, ASDW]

The stages of SMO object creation are as follows:

  1. Create an instance of the object.

  2. Set the object properties.

  3. Create instances of the child objects.

  4. Set the child object properties.

  5. Create the object.

When instances of SMO objects are created in an SMO application, they do not exist on the instance of [!INCLUDEssNoVersion] until the Create method is issued. However, it is not necessary to issue a Create method for every individual object. If an object has a set of child objects, only the parent object is required to run the Create method. For example, the definition of a table requires that it contains at least one column to exist. Also, a column cannot exist in isolation without a table. There is a codependent relationship between the table and its columns.

The xref:Microsoft.SqlServer.Management.Dmf.Policy.Alter%2A method lets you make changes to an object. Several changes to an object, such as adding child objects to one of the object's collections or changing a property value, are batched together and run as one. The Alter method reduces network traffic and improves overall performance.

The Drop statement is used to remove an object and all its codependent child objects that were required to create the object initially.

See Also

SMO Object Model