다음을 통해 공유


Create 명령(TMSL)

적용 대상: SQL Server 2016 이상 Analysis Services Azure Analysis Services Fabric/Power BI Premium

지정된 개체와 지정된 모든 하위 개체를 만듭니다. 개체가 이미 있는 경우 명령은 오류를 발생합니다.

요청

요청의 구조는 개체에 따라 달라집니다. 부모인 개체에는 모든 자식이 포함되어야 하지만 형제 및 부모의 전체 개체 정의는 필요하지 않습니다.

데이터베이스 개체(TMSL) 서버에 데이터베이스를 추가합니다.

{   
  "create": {   
    "database": {   
      "name": "AdventureworksDW2016",   
      "description": "<description>"   
    }   
  }   
}  

DataSources 개체(TMSL)

{  
  "create": {  
    "parentObject": {  
      "database": "AdventureworksDW2016"  
    },  
    "dataSource": {  
      "name": "SqlServer localhost AdventureworksDW2016",  
      "connectionString": "Provider=SQLNCLI11;Data Source=localhost;Initial Catalog=AdventureworksDW2016;Integrated Security=SSPI;Persist Security Info=false",  
      "impersonationMode": "impersonateAccount",  
      "account": "<account name>",  
      "annotations": [  
        {  
          "name": "ConnectionEditUISource",  
          "value": "SqlServer"  
        }  
      ]  
    }  
  }  
}  

Partitions 개체(TMSL) 부모 테이블 개체에 파티션을 추가합니다.

{  
  "create": {  
    "parentObject": {  
      "database": "AdventureWorksTabular1200",  
      "table": "Date"  
    },  
    "partition": {  
      "name": "Date 2",  
      "source": {  
        "query": "SELECT [dbo].[DimDate].* FROM [dbo].[DimDate]",  
        "dataSource": "SqlServer localhost AdventureworksDW2016"  
      }  
    }  
  }  
}  

Roles 개체(TMSL) 데이터베이스에 역할을 최소한으로 추가하지만 멤버 자격이나 필터는 추가하지 않습니다.

{  
  "create": {  
    "parentObject": {  
      "database": "AdventureWorksDW2016"  
    },  
    "role": {  
      "name": "DataReader",  
      "modelPermission": "read"  
    }  
  }  
}  

Database 개체를 제외하고 생성되는 개체는 지정된 parentObject의 자식입니다. Database 개체의 부모는 항상 Server 개체입니다.

서버는 컨텍스트에서 가정됩니다. 예를 들어 Management Studio 또는 AMO PowerShell에서 스크립트를 실행하는 경우 서버 연결은 세션 또는 매개 변수로 지정됩니다.

응답

명령이 성공하면 빈 결과를 반환합니다. 그렇지 않으면 XMLA 예외가 반환됩니다.

예제

예제 1 - 멤버 자격 및 필터를 지정하는 역할을 추가합니다.

{   
   "create":{   
      "parentObject":{   
         "database":"AdventureWorksTabular1200"  
      },  
      "role":{  
         "name":"DataReader",  
         "modelPermission":"read",  
         "members":[   
            {  
               "memberName": "account-01",  
               "memberId":"S-1-5-21-1111111111-2222222222-33333333-444444"  
            },  
            {   
               "memberName": "account-02",  
               "memberId":"S-2-5-21-1111111111-2222222222-33333333-444444"  
            }  
         ],  
         "tablePermissions":[   
            {   
               "name":"Date",  
               "filterExpression":"CalendarYear('2011')"  
            }  
         ]  
      }  
   }  
}  

사용량(엔드포인트)

이 명령 요소는 다음과 같은 방법으로 노출되는 XMLA 엔드포인트를 통해 XMLA(Execute 메서드) 호출의 문에 사용됩니다.

  • SSMS(SQL Server Management Studio)의 XMLA 창으로

  • invoke-ascmd PowerShell cmdlet에 대한 입력 파일로

  • SSIS 작업 또는 SQL Server 에이전트 작업에 대한 입력으로

SSMS에서 이 명령에 대한 즉시 만든 스크립트를 생성할 수 있습니다. 예를 들어 기존 데이터베이스 스크립트>스크립트 데이터베이스>를CREATE To로 마우스 오른쪽 단추로 > 클릭할 수 있습니다.