> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-detect-table-modification.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Cloud にファイルをアップロードする

> Cloud にファイルをアップロードする方法

export const Image = ({img, alt, size = "lg"}) => {
  const normalizedSize = ["sm", "md", "lg"].includes(size) ? size : "lg";
  return <div className={`ch-image-${normalizedSize}`}>
      <Frame>
        <img src={img} alt={alt} />
      </Frame>
    </div>;
};

ClickHouse Cloud では、ファイルを簡単にインポートでき、以下の
フォーマットをサポートしています。

| Format                          |
| ------------------------------- |
| `CSV`                           |
| `CSVWithNamesAndTypes`          |
| `CSVWithNames`                  |
| `JSONEachRow`                   |
| `TabSeparated`                  |
| `TabSeparatedWithNames`         |
| `TabSeparatedWithNamesAndTypes` |

<Steps>
  <Step>
    ## ファイルをアップロードする

    Cloud のホーム画面で、以下のようにサービスを選択します。

    <Image img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/I0yKDIFW2QfsHJIe/images/cloud/migrate/csv_01.webp?fit=max&auto=format&n=I0yKDIFW2QfsHJIe&q=85&s=ca931639add4b1448f9871bb4dc5a7d5" alt="upload_file_02" width="3024" height="1483" data-path="images/cloud/migrate/csv_01.webp" />

    サービスがアイドル状態の場合は、起動する必要があります。

    以下のように、左側のタブで `Data sources` を選択します。

    <Image img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/I0yKDIFW2QfsHJIe/images/cloud/migrate/csv_02.webp?fit=max&auto=format&n=I0yKDIFW2QfsHJIe&q=85&s=3d07583e0f23db5a86d43b81683bfca3" alt="upload_file_03" width="3024" height="1483" data-path="images/cloud/migrate/csv_02.webp" />

    次に、data sources ページの右側で `Upload a file` を選択します。

    <Image img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/I0yKDIFW2QfsHJIe/images/cloud/migrate/csv_03.webp?fit=max&auto=format&n=I0yKDIFW2QfsHJIe&q=85&s=1032b014a1f523d65877906a01f4dede" alt="upload_file_04" width="3024" height="1483" data-path="images/cloud/migrate/csv_03.webp" />

    ファイル選択ダイアログが表示され、Cloud サービス上のテーブルにデータを
    挿入するためのファイルを選択できます。

    <Image img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/I0yKDIFW2QfsHJIe/images/cloud/migrate/csv_04.webp?fit=max&auto=format&n=I0yKDIFW2QfsHJIe&q=85&s=9a1bfd3707e7f3b25f43819a43b9b013" alt="upload_file_05" width="1267" height="736" data-path="images/cloud/migrate/csv_04.webp" />
  </Step>

  <Step>
    ## テーブルを設定する

    ファイルのアップロードが完了すると、データの挿入先となるテーブルを
    設定できます。先頭 3 行を含むテーブルのプレビューも表示されます。

    <Image img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/I0yKDIFW2QfsHJIe/images/cloud/migrate/csv_08.webp?fit=max&auto=format&n=I0yKDIFW2QfsHJIe&q=85&s=3884126b5640d94ce4b914553d2ccfb2" alt="upload_file_08" width="3018" height="1476" data-path="images/cloud/migrate/csv_08.webp" />

    次に、宛先テーブルを選択できます。選択肢は次のとおりです。

    * 新しいテーブル
    * 既存のテーブル

    <br />

    データのアップロード先データベースを指定でき、新しいテーブルの場合は、
    作成するテーブル名も指定できます。また、ソートキーも選択できます。

    <Image img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/I0yKDIFW2QfsHJIe/images/cloud/migrate/csv_05.webp?fit=max&auto=format&n=I0yKDIFW2QfsHJIe&q=85&s=e40f9092ae156aa556931da54266b47c" alt="upload_file_05" width="3016" height="1474" data-path="images/cloud/migrate/csv_05.webp" />

    ファイルから読み取られたカラムは `Source field` として表示され、各フィールドについて
    次の項目を変更できます。

    * 推定された型
    * デフォルト値
    * カラムを [Nullable](/ja/reference/data-types/nullable) にするかどうか

    <Image img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/I0yKDIFW2QfsHJIe/images/cloud/migrate/csv_06.webp?fit=max&auto=format&n=I0yKDIFW2QfsHJIe&q=85&s=05557d10090cef86422e21a7864467cb" alt="upload_file_06" width="3012" height="1476" data-path="images/cloud/migrate/csv_06.webp" />

    <Info>
      **フィールドの除外**

      インポートに含めたくない場合は、フィールドを削除することもできます。
    </Info>

    使用するテーブルエンジンの種類を指定できます。

    * `MergeTree`
    * `ReplacingMergeTree`
    * `SummingMergeTree`
    * `Null`

    <br />

    パーティションキー式とプライマリ
    キー式を指定できます。

    <Image img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/I0yKDIFW2QfsHJIe/images/cloud/migrate/csv_07.webp?fit=max&auto=format&n=I0yKDIFW2QfsHJIe&q=85&s=59c50fd3731146138bc6e5b65b4e13bf" alt="upload_file_07" width="3004" height="1476" data-path="images/cloud/migrate/csv_07.webp" />

    データをインポートするには、`Import to ClickHouse` (上図参照) をクリックします。データのインポートはキューに追加され、
    以下に示すように `Status` カラムの `queued` ステータスバッジで確認できます。また、
    `Open as query` (上図参照) をクリックすると、SQL コンソールで INSERT クエリを開くこともできます。このクエリは、
    `URL` table function を使用して S3 バケットにアップロードされたファイルを挿入します。

    <Image img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/I0yKDIFW2QfsHJIe/images/cloud/migrate/csv_09.webp?fit=max&auto=format&n=I0yKDIFW2QfsHJIe&q=85&s=cefe5ef966512145b561ede5ff6db4e3" alt="upload_file_09" width="1271" height="487" data-path="images/cloud/migrate/csv_09.webp" />

    ジョブが失敗すると、`Data upload history` タブの `Status` カラムに
    `failed` ステータスバッジが表示されます。`View Details` をクリックすると、
    アップロードが失敗した理由の詳細を確認できます。失敗した INSERT のエラーメッセージに基づいて、
    テーブル設定を修正したり、データをクリーンアップしたりする必要がある場合があります。

    <Image img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/I0yKDIFW2QfsHJIe/images/cloud/migrate/csv_10.webp?fit=max&auto=format&n=I0yKDIFW2QfsHJIe&q=85&s=486221ac49f07bb4490975262dec1fb7" alt="upload_file_11" width="1260" height="262" data-path="images/cloud/migrate/csv_10.webp" />
  </Step>
</Steps>
