Table.Drop Table.Drop Table.Drop Method

정의

데이터베이스에서 테이블을 제거합니다. Removes the table from the database.

public:
 virtual void Drop();
public void Drop ();
Public Sub Drop ()

예제

다음 코드 예에서는 테이블을 만든 다음 삭제하는 방법을 보여 줍니다.The following code example shows how to create, and then drop a table.

C#C#

Server srv = new Server("(local)");  
Database db = srv.Databases["AdventureWorks2012"];  

Table tb = new Table(db, "Test Table");  
Column col1 = new Column(tb, "Name", DataType.NChar(50));  
Column col2 = new Column(tb, "ID", DataType.Int);  

tb.Columns.Add(col1);   
tb.Columns.Add(col2);   
tb.Create();  
tb.Drop();  

PowershellPowershell

#Connect to the local server and get the AdventureWorks2012 database  
$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")  
$db = New-Object Microsoft.SqlServer.Management.Smo.Database  
$db = $srv.Databases.Item("AdventureWorks2012")  

#Create the Table  
$tb = new-object Microsoft.SqlServer.Management.Smo.Table($db, "Test Table")  
$col1 = new-object Microsoft.SqlServer.Management.Smo.Column($tb, "Name", [Microsoft.SqlServer.Management.Smo.DataType]::NChar(50))  
$col2 = new-object Microsoft.SqlServer.Management.Smo.Column($tb, "ID", [Microsoft.SqlServer.Management.Smo.DataType]::Int)  
$tb.Columns.Add($col1)  
$tb.Columns.Add($col2)  
$tb.Create()  
$tb.Drop()  

적용 대상

추가 정보