To import data into TDSQL-C PostgreSQL, you can use the COPY command or the \copy meta-command in psql, which is a command-line interface for PostgreSQL. Here’s how you can do it:
COPY CommandThe COPY command is a high-performance way to load large amounts of data into a table. It can read data from a file on the server or from standard input.
Example:
COPY my_table FROM '/path/to/datafile.csv' WITH (FORMAT csv, HEADER true);
In this example, my_table is the name of the table you want to import data into, and /path/to/datafile.csv is the path to the CSV file containing the data. The FORMAT csv specifies that the file is in CSV format, and HEADER true indicates that the first line of the file contains column headers.
\copy Meta-CommandThe \copy meta-command is used in the psql command-line interface and is a convenient way to import data from a client machine.
Example:
\copy my_table FROM '/local/path/to/datafile.csv' WITH (FORMAT csv, HEADER true);
In this example, /local/path/to/datafile.csv is the path to the CSV file on your local machine.
If you are using Tencent Cloud TDSQL-C PostgreSQL, you can follow these steps to import data:
psql or a GUI tool like pgAdmin to connect to your TDSQL-C PostgreSQL instance.COPY or \copy Command: As described above, use the COPY command if the file is on the server or \copy if the file is on your local machine.By following these steps, you can efficiently import data into your TDSQL-C PostgreSQL database.