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

# Upload files to Cloud

> Learn how to upload files to 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 provides an easy way to import your files and supports the
following formats:

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

<Steps>
  <Step title="Upload a file" id="upload-file">
    From the Cloud homepage, select your service as shown below:

    <Image img="https://mintcdn.com/private-7c7dfe99-postgresql-tls-support/2QCOf7xGnBQgqjDM/images/cloud/migrate/csv_01.webp?fit=max&auto=format&n=2QCOf7xGnBQgqjDM&q=85&s=08894efadd065f0129e0845d44207564" alt="upload_file_02" width="3024" height="1483" data-path="images/cloud/migrate/csv_01.webp" />

    If your service is idle you will need to wake it.

    Select `Data sources` in the left hand tab as shown below:

    <Image img="https://mintcdn.com/private-7c7dfe99-postgresql-tls-support/2QCOf7xGnBQgqjDM/images/cloud/migrate/csv_02.webp?fit=max&auto=format&n=2QCOf7xGnBQgqjDM&q=85&s=b156c5d2337583efe03abb9d26733633" alt="upload_file_03" width="3024" height="1483" data-path="images/cloud/migrate/csv_02.webp" />

    Next select `Upload a file` on the right side of the data sources page:

    <Image img="https://mintcdn.com/private-7c7dfe99-postgresql-tls-support/2QCOf7xGnBQgqjDM/images/cloud/migrate/csv_03.webp?fit=max&auto=format&n=2QCOf7xGnBQgqjDM&q=85&s=4897e4396d39e46c8ae1e1722c2fa30d" alt="upload_file_04" width="3024" height="1483" data-path="images/cloud/migrate/csv_03.webp" />

    A file dialogue will pop up allowing you to select the file that you wish to
    use to insert data into a table on your Cloud service.

    <Image img="https://mintcdn.com/private-7c7dfe99-postgresql-tls-support/2QCOf7xGnBQgqjDM/images/cloud/migrate/csv_04.webp?fit=max&auto=format&n=2QCOf7xGnBQgqjDM&q=85&s=af53107b8ead2479d6a0c572f4c10215" alt="upload_file_05" width="1267" height="736" data-path="images/cloud/migrate/csv_04.webp" />
  </Step>

  <Step title="Configure table" id="configure-table">
    Once the file has uploaded you will be able to configure the table where you want
    to insert the data to. A preview of the table with the first three rows is shown.

    <Image img="https://mintcdn.com/private-7c7dfe99-postgresql-tls-support/2QCOf7xGnBQgqjDM/images/cloud/migrate/csv_08.webp?fit=max&auto=format&n=2QCOf7xGnBQgqjDM&q=85&s=52f227296cb7ee1bd0c85f2ad61e3b05" alt="upload_file_08" width="3018" height="1476" data-path="images/cloud/migrate/csv_08.webp" />

    You can now select a destination table. The options are:

    * a new table
    * an existing table

    <br />

    You can specify which database you want to upload the data to, and in the case of
    a new table, the name of the table that will be created. You will also be able to select the sorting key:

    <Image img="https://mintcdn.com/private-7c7dfe99-postgresql-tls-support/2QCOf7xGnBQgqjDM/images/cloud/migrate/csv_05.webp?fit=max&auto=format&n=2QCOf7xGnBQgqjDM&q=85&s=9be769cc1d35ad28e0b72c0ff952829a" alt="upload_file_05" width="3016" height="1474" data-path="images/cloud/migrate/csv_05.webp" />

    Columns read from the file are shown as `Source field`s and for each field, you
    can change:

    * the inferred type
    * the default value
    * whether to make the column [Nullable](/reference/data-types/nullable) or not

    <Image img="https://mintcdn.com/private-7c7dfe99-postgresql-tls-support/2QCOf7xGnBQgqjDM/images/cloud/migrate/csv_06.webp?fit=max&auto=format&n=2QCOf7xGnBQgqjDM&q=85&s=0a537d8db808c073e427ae89ff3a425c" alt="upload_file_06" width="3012" height="1476" data-path="images/cloud/migrate/csv_06.webp" />

    <Info>
      **Excluding fields**

      You can also remove a field if you don't want to include it in the import
    </Info>

    You can specify the type of table engine that you want to use:

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

    <br />

    You can specify a partitioning key expression and primary
    key expression.

    <Image img="https://mintcdn.com/private-7c7dfe99-postgresql-tls-support/2QCOf7xGnBQgqjDM/images/cloud/migrate/csv_07.webp?fit=max&auto=format&n=2QCOf7xGnBQgqjDM&q=85&s=ef8e17f27335222f4fb633f4803adf3e" alt="upload_file_07" width="3004" height="1476" data-path="images/cloud/migrate/csv_07.webp" />

    Click `Import to ClickHouse` (shown above) to import the data. The data import will be queued as
    indicated by the `queued` status badge in the `Status` column as shown below. You can also click
    `Open as query` (shown above) to open the insert query in the SQL console. The query will insert
    the file which was uploaded to an S3 bucket using the `URL` table function.

    <Image img="https://mintcdn.com/private-7c7dfe99-postgresql-tls-support/2QCOf7xGnBQgqjDM/images/cloud/migrate/csv_09.webp?fit=max&auto=format&n=2QCOf7xGnBQgqjDM&q=85&s=c1ea2e99081b657024b806a8b789c52b" alt="upload_file_09" width="1271" height="487" data-path="images/cloud/migrate/csv_09.webp" />

    If the job fails you will see a `failed` status badge under the `Status` column of
    the `Data upload history` tab. You can click `View Details` for more information
    on why the upload failed. You may need to modify the table configuration or clean
    the data based on the error message for the failed insert.

    <Image img="https://mintcdn.com/private-7c7dfe99-postgresql-tls-support/2QCOf7xGnBQgqjDM/images/cloud/migrate/csv_10.webp?fit=max&auto=format&n=2QCOf7xGnBQgqjDM&q=85&s=05250476ae4330c90d189a68772466ba" alt="upload_file_11" width="1260" height="262" data-path="images/cloud/migrate/csv_10.webp" />
  </Step>
</Steps>
