Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Yandex Managed Service for PostgreSQL
  • Getting started
    • All guides
      • Connecting to a database
      • SQL queries in Yandex WebSQL
      • Copying and populating a table
      • Managing databases
  • Access management
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Public materials
  • Release notes

In this article:

  • Getting started
  • Copying data from a table
  • Populating a table with data
  1. Step-by-step guides
  2. Databases
  3. Copying and populating a table

Copying and populating a table from a local machine

Written by
Yandex Cloud
Updated at November 10, 2023
  • Getting started
  • Copying data from a table
  • Populating a table with data

You can both copy data from a table to a local file and populate a table with data from a local file using the psql interactive terminal.

Getting startedGetting started

  1. Get an SSL certificate.

  2. Install the dependencies:

    sudo apt update && sudo apt install --yes postgresql-client
    

Copying data from a tableCopying data from a table

To copy table data to a file, run this command:

psql "host=c-<cluster_ID>.rw.mdb.yandexcloud.net \
    port=6432 \
    sslmode=verify-full \
    dbname=<DB_name> \
    user=<username> \
    target_session_attrs=read-write" \
    -c "\copy (SELECT * FROM <table_name>) to stdout(DELIMITER '<delimiter_character>')" \
    >> <local_file_name>

Populating a table with dataPopulating a table with data

Note

You need to create a table in advance. The number of columns and data types in a local file must match the Managed Service for PostgreSQL table parameters.

To populate your table with data from a local file, run this command:

cat <local_file_name> | \
psql "host=c-<cluster_ID>.rw.mdb.yandexcloud.net \
    port=6432 \
    sslmode=verify-full \
    dbname=<DB_name> \
    user=<username> \
    target_session_attrs=read-write" \
    -c "COPY <table_name> FROM stdin (DELIMITER '<delimiter_character>')"

Was the article helpful?

Previous
SQL queries in Yandex WebSQL
Next
Managing databases
© 2025 Direct Cursus Technology L.L.C.