sp_adddistributiondb(Transact-SQL)

새 배포 데이터베이스를 만들고 배포자 스키마를 설치합니다. 배포 데이터베이스는 복제에 사용하는 프로시저, 스키마 및 메타데이터를 저장합니다. 이 저장 프로시저는 배포 데이터베이스를 만들기 위해 master 데이터베이스의 배포자에서 실행되며 복제 배포를 사용하는 데 필요한 테이블 및 저장 프로시저를 설치합니다.

항목 링크 아이콘Transact-SQL 구문 표기 규칙

구문

sp_adddistributiondb [ @database= ] 'database' 
    [ , [ @data_folder= ] 'data_folder' ] 
    [ , [ @data_file= ] 'data_file' ] 
    [ , [ @data_file_size= ] data_file_size ] 
    [ , [ @log_folder= ] 'log_folder' ] 
    [ , [ @log_file= ] 'log_file' ] 
    [ , [ @log_file_size= ] log_file_size ] 
    [ , [ @min_distretention= ] min_distretention ] 
    [ , [ @max_distretention= ] max_distretention ] 
    [ , [ @history_retention= ] history_retention ] 
    [ , [ @security_mode= ] security_mode ] 
    [ , [ @login= ] 'login' ] 
    [ , [ @password= ] 'password' ] 
    [ , [ @createmode= ] createmode ]
    [ , [ @from_scripting = ] from_scripting ]

인수

  • [ [ @database=] database'
    만들 배포 데이터베이스의 이름입니다. database는 sysname이며 기본값은 없습니다. 지정한 데이터베이스가 이미 존재하지만 아직 배포 데이터베이스로 표시되지 않은 경우 배포를 활성화하는 데 필요한 개체가 설치되고 데이터베이스가 배포 데이터베이스로 표시됩니다. 지정한 데이터베이스가 이미 배포 데이터베이스로 활성화된 경우 오류가 반환됩니다.

  • [ [ @data_folder=] **'**data_folder'
    배포 데이터베이스 데이터 파일을 저장하는 데 사용되는 디렉터리의 이름입니다. data_folder는 nvarchar(255)이며 기본값은 NULL입니다. NULL인 경우 MicrosoftSQL Server의 해당 인스턴스에 대한 데이터 디렉터리(예: C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\Data)가 사용됩니다.

  • [ [ @data_file=] 'data_file'
    데이터베이스 파일의 이름입니다. data_file은 nvarchar(255)이며 기본값은 database입니다. NULL인 경우 저장 프로시저는 데이터베이스 이름을 사용하여 새 파일 이름을 생성합니다.

  • [ [ @data_file_size=] data_file_size
    초기 데이터 파일 크기(MB)입니다. data_file_size는 int이며 기본값은 5MB입니다.

  • [ [ @log_folder=] 'log_folder'
    데이터베이스 로그 파일용 디렉터리의 이름입니다. log_folder는 nvarchar(255)이며 기본값은 NULL입니다. NULL인 경우 SQL Server의 해당 인스턴스(예: C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\Data)에 대한 데이터 디렉터리가 사용됩니다.

  • [ [ @log_file=] 'log_file'
    로그 파일의 이름입니다. log_file은 nvarchar(255)이며 기본값은 NULL입니다. NULL인 경우 저장 프로시저는 데이터베이스 이름을 사용하여 새 파일 이름을 생성합니다.

  • [ [ @log_file_size=] log_file_size
    초기 로그 파일 크기(MB)입니다. log_file_size는 int이며 기본값은 0MB입니다. 이 기본값은 SQL Server에서 허용하는 가장 작은 로그 파일 크기를 사용하여 만든 파일 크기를 나타냅니다.

  • [ [ @min_distretention=] min_distretention
    배포 데이터베이스에서 트랜잭션을 삭제하기 전의 최소 보존 기간(시간)입니다. min_distretention은 int이며 기본값은 0시간입니다.

  • [ [ @max_distretention=] max_distretention
    트랜잭션을 삭제하기 전의 최대 보존 기간(시간)입니다. max_distretention은 int이며 기본값은 72시간입니다. 배포의 최대 보존 기간보다 오래된 복제 명령을 받지 않은 구독은 비활성 상태로 표시되어 다시 초기화해야 합니다. RAISERROR 21011 오류는 각 비활성 구독에 대해 발생됩니다. 0 값은 복제된 트랜잭션이 배포 데이터베이스에 저장되지 않음을 의미합니다.

  • [ [ @history_retention=] history_retention
    기록을 보존할 기간(시간)입니다. history_retention은 int이며 기본값은 48시간입니다.

  • [ [ @security_mode=] security_mode
    배포자에 연결할 때 사용할 보안 모드입니다. security_mode는 int이며 기본값은 1입니다. 0은 SQL Server 인증을 지정하고 1은 Windows 통합 인증을 지정합니다.

  • [ [ @login=] 'login'
    배포 데이터베이스를 만들기 위해 배포자에 연결할 때 사용하는 로그인 이름입니다. security_mode를 0으로 설정한 경우 필요합니다. login은 sysname이며 기본값은 NULL입니다.

  • [ [ @password=] 'password'
    배포자에 연결할 때 사용하는 암호입니다. security_mode가 0으로 설정된 경우 필요합니다.password는 sysname이고 기본값은 NULL입니다.

  • [ @createmode=] createmode
    createmode는 int이고 기본값은 1이며 다음 값 중 하나일 수 있습니다.

    설명

    0

    정보를 제공하기 위해서만 확인됩니다. 지원되지 않습니다. 향후 호환성은 보장되지 않습니다.

    1(기본값)

    CREATE DATABASE 또는 기존 데이터베이스를 사용한 다음 배포 데이터베이스에 복제 개체를 만들기 위해 instdist.sql 파일을 적용합니다.

    2

    정보를 제공하기 위해서만 확인됩니다. 지원되지 않습니다. 향후 호환성은 보장되지 않습니다.

  • [ @from_scripting = ] from_scripting
    정보를 제공하기 위해서만 확인됩니다. 지원되지 않습니다. 향후 호환성은 보장되지 않습니다.

반환 코드 값

0(성공) 또는 1(실패)

주의

sp_adddistributiondb는 모든 유형의 복제에서 사용됩니다. 단, 이 저장 프로시저는 배포자에서만 실행합니다.

sp_adddistributiondb를 실행하기 전에 sp_adddistributor를 실행하여 배포자를 구성해야 합니다.

sp_adddistributiondb를 실행하기 이전에sp_adddistributor를 실행합니다.

-- This script uses sqlcmd scripting variables. They are in the form
-- $(MyVariable). For information about how to use scripting variables  
-- on the command line and in SQL Server Management Studio, see the 
-- "Executing Replication Scripts" section in the topic
-- "Programming Replication Using System Stored Procedures".

-- Install the Distributor and the distribution database.
DECLARE @distributor AS sysname;
DECLARE @distributionDB AS sysname;
DECLARE @publisher AS sysname;
DECLARE @directory AS nvarchar(500);
DECLARE @publicationDB AS sysname;
-- Specify the Distributor name.
SET @distributor = $(DistPubServer);
-- Specify the distribution database.
SET @distributionDB = N'distribution';
-- Specify the Publisher name.
SET @publisher = $(DistPubServer);
-- Specify the replication working directory.
SET @directory = N'\\' + $(DistPubServer) + '\repldata';
-- Specify the publication database.
SET @publicationDB = N'AdventureWorks'; 

-- Install the server MYDISTPUB as a Distributor using the defaults,
-- including autogenerating the distributor password.
USE master
EXEC sp_adddistributor @distributor = @distributor;

-- Create a new distribution database using the defaults, including
-- using Windows Authentication.
USE master
EXEC sp_adddistributiondb @database = @distributionDB, 
    @security_mode = 1;
GO

-- Create a Publisher and enable AdventureWorks for replication.
-- Add MYDISTPUB as a publisher with MYDISTPUB as a local distributor
-- and use Windows Authentication.
DECLARE @distributionDB AS sysname;
DECLARE @publisher AS sysname;
-- Specify the distribution database.
SET @distributionDB = N'distribution';
-- Specify the Publisher name.
SET @publisher = $(DistPubServer);

USE [distribution]
EXEC sp_adddistpublisher @publisher=@publisher, 
    @distribution_db=@distributionDB, 
    @security_mode = 1;
GO 

사용 권한

sysadmin 고정 서버 역할의 멤버만이 sp_adddistributiondb를 실행할 수 있습니다.