> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sync.cdata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# PostgreSQL (Native)

export const CommonDatasourceMoreInformation = ({datasource = "the data source", advancedurl = "", siteName = "CData Sync", driverVersion = ""}) => {
  return <>
      <p>
        {siteName} と{datasource} の連携について、詳しくは{' '}
        <a href={`https://cdn.cdata.com/help/${advancedurl}${driverVersion}/jp/synch/default.htm`}>
          {datasource} Connector for {siteName}
        </a> を参照してください。
      </p>
    </>;
};

export const CommonDatasourceAddConnector = ({datasource = "the data source", title = "the connector", destination = false, siteNameShort = "Sync"}) => {
  return <>
      <p>
        {siteNameShort} で{datasource} のデータを使用できるようにするには、まず以下の手順でコネクタを追加する必要があります：
      </p>
      <ol>
        <li>{siteNameShort} のダッシュボードから<strong>接続</strong>ページを開きます。</li>
        <li><strong>接続を追加</strong>をクリックして<strong>コネクタを選択</strong>ページを開きます。</li>
        <li>
          <strong>{destination ? "同期先" : "データソース"}</strong>タブをクリックして
          <strong>{title}</strong> 行に移動します。
        </li>
        <li>
          行末にある<strong>接続を設定</strong>アイコンをクリックして、<strong>新しい接続</strong>ページを開きます。この操作により、{' '}
          <strong>接続を追加</strong>ダイアログボックスが開きます。
          <br />
          <strong>Note：</strong> <strong>接続を設定</strong>アイコンが表示されない場合は、<strong>コネクタをダウンロード</strong>アイコンをクリックして {title} コネクタをインストールしてください。
        </li>
        <li><strong>接続を追加</strong>ダイアログボックスに接続名を入力します。</li>
        <li><strong>追加</strong>をクリックして、コネクタの<strong>設定</strong>タブを開きます。</li>
      </ol>
      <p>
        新しいコネクタのインストールについての詳細は、{' '}
        <a href="../connections">接続</a>を参照してください。
      </p>
    </>;
};

export const CommonDatasourceIntroSource = ({datasource = "the data source", siteName = "CData Sync"}) => {
  return <p>
      {siteName} アプリケーションから{datasource} コネクタを使用して、{datasource} からデータを取得してサポートされている任意の同期先に移動できます。これを行うには、コネクタを追加し、コネクタへの認証を行い、接続を完了する必要があります。
    </p>;
};

export const driverVersion = "M";

export const siteNameShort = "Sync";

export const siteName = "CData Sync";

export const datasource = "PostgreSQL";
export const pageTitle = "PostgreSQL (Native)";
export const advancedurl = "FP";

<CommonDatasourceIntroSource datasource={datasource} siteName={siteName} />

<Note>This connection can be used <u>only as a source</u> for the **Change Data Capture** job type.</Note>

## Prerequisites

Before you add and set up the {datasource} source connector, you need to set up {datasource} for change data capture (CDC), as explained in the following sections.

### Minimum Requirements

Before you set up {datasource} for CDC, ensure that you have the following minimum requirements:

* **{datasource} Version:** Version 12 or later

  <Note>Only databases with the UTF-8 character encoding are supported for CDC. Strings that contain extended ASCII characters might not be processed correctly during the incremental replication.</Note>

* **User Privileges:** LOGIN and REPLICATION (the minimum privileges that are required for connecting to PostgreSQL and reading the replication slot)

### Set Up PostgreSQL for CDC

Perform the following steps to enable logical replication, specify which tables to replicate, and create a logical replication slot for {siteNameShort}.

1. Ensure that the `wal_level` parameter is set in your {datasource} database, as follows:

   1. Verify the current `wal_level` setting in {datasource} by submitting the following query:

      ```
      SHOW wal_level;
      ```

   2. Set the `wal_level` parameter to enable logical replication in either of the following ways:

      **Method 1:** Execute the following command:

      `ALTER SYSTEM SET wal_level = logical;`

      <br />

      <br />

      **Method 2:** Set `wal_level = logical` manually in your {datasource} file, as shown below:

      ```
      # REPLICATION
      wal_level = logical   
      ```

   <Note>Regardless of which method you use, you **must restart the {datasource} database** for the changes to take effect.</Note>

2. Create a publication to specify which tables to replicate.

   ```
   CREATE PUBLICATION cdatasync_pub1 FOR TABLE table1, table2, ...;
   ```

   You can also create a publication for all tables in the database, as shown below.

   ```
   CREATE PUBLICATION cdatasync_pub1 FOR ALL TABLES;
   ```

   <Note>SUPERUSER privileges are required when you create a publication for all tables.</Note>

3. Create a logical replication slot for {siteNameShort} by submitting the following SELECT statement:

   ```
   SELECT pg_create_logical_replication_slot('SlotName', 'pgoutput');
   ```

   <Note>When you create the logical replication slot, you must use the `pgoutput` plugin.</Note>

## PostgreSQL コネクタを追加

<CommonDatasourceAddConnector datasource={datasource} title={pageTitle} destination={false} siteNameShort={siteNameShort} />

## PostgreSQL への認証

After you add the connector, you need to set the required properties.

* **Host:** Enter the host name or IP of the server that hosts the {datasource} database. The default server value is **localhost**.
* **Port:** Enter the port number of the server that hosts the {datasource} database. The default port value is **5432**.
* **Database:** Enter the name of the database that to which you want to connect when you connect to the {datasource} server. The default database is **postgres**.
* **User:** Enter the username that you use to authenticate to your {datasource} account.
* **Password:** Enter the password that you use to authenticate to your {datasource} account.

## 接続を完了する

To complete your connection:

1. Define advanced connection settings on the **Advanced** tab. (In most cases, though, you should not need these settings.)
2. Click **Create & Test** to create your connection.

## 詳細について

<CommonDatasourceMoreInformation datasource={datasource} advancedurl={advancedurl} siteName={siteName} driverVersion={driverVersion} />
