Writing data to S3 buckets (Yandex Object Storage)
In YDB, you can use external connections or external tables to write data to the Yandex Object Storage bucket.
Writing data via external connection
Using connections for data writing is convenient for prototyping and initial setup. The SQL expression demonstrates writing data directly to an external data source.
INSERT INTO `connection`.`test/`
WITH
(
FORMAT = "csv_with_names"
)
SELECT
"value" AS value, "name" AS name
The data will be written to the specified path. In this mode, the resulting files will not be partitioned. If you need to partition the resulting files, use writing via external tables. The files created during the writing process are assigned random names.
When working with external connections, only read (SELECT
) and insert (INSERT
) operations are possible; other types of operations are not supported.
Writing data via external tables
If you need to write data regularly, doing this using external tables is convenient. In this case, there is no need to specify all the details of working with this data in each query. To write data to the bucket, create an external table in S3 (Yandex Object Storage) and use the usual SQL INSERT INTO
statement:
INSERT INTO `test`
SELECT
"value" AS value, "name" AS name