forked from docs/doc-exports
Reviewed-by: Kacur, Michal <michal.kacur@t-systems.com> Co-authored-by: Lu, Huayi <luhuayi@huawei.com> Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
17 lines
3.0 KiB
HTML
17 lines
3.0 KiB
HTML
<a name="EN-US_TOPIC_0000001381808753"></a><a name="EN-US_TOPIC_0000001381808753"></a>
|
|
|
|
<h1 class="topictitle1">How Do I Use \Copy to Import and Export Data?</h1>
|
|
<div id="body0000001381808753"><p id="EN-US_TOPIC_0000001381808753__en-us_topic_0000001099136620_p8693312111414">GaussDB(DWS) is a fully managed service on the cloud. Users cannot log in to the background to import or export data by using <strong id="EN-US_TOPIC_0000001381808753__b1739155863814">COPY</strong>, so the <strong id="EN-US_TOPIC_0000001381808753__b1473916583383">COPY</strong> syntax is disabled. You are advised to store data files on OBS and use OBS foreign tables to import data. If you want to use <strong id="EN-US_TOPIC_0000001381808753__b116061156153814">COPY</strong> to import and export data, perform the following operations:</p>
|
|
<ol id="EN-US_TOPIC_0000001381808753__en-us_topic_0000001099136620_ol16207174791517"><li id="EN-US_TOPIC_0000001381808753__en-us_topic_0000001099136620_li192071547111510">Place the data file on the client.</li><li id="EN-US_TOPIC_0000001381808753__en-us_topic_0000001099136620_li0208047171518">Use gsql to connect to the target cluster.</li><li id="EN-US_TOPIC_0000001381808753__en-us_topic_0000001099136620_li142088479158">Run the following command to import data. Enter the directory name and file name of the data file on the client and specify the import option in <strong id="EN-US_TOPIC_0000001381808753__b146761412391">with</strong>. The command is almost the same as the common <strong id="EN-US_TOPIC_0000001381808753__b16825410392">COPY</strong> command. You only need to add a backslash (\) before the command. When the data is successfully imported, no notification will be displayed.<pre class="screen" id="EN-US_TOPIC_0000001381808753__en-us_topic_0000001099136620_screen16315251121617">\copy tb_name from '/directory_name/file_name' with(...);</pre>
|
|
</li><li id="EN-US_TOPIC_0000001381808753__li1122954181013">Run the following command to export data to a local file. Retain the default settings of parameters.<pre class="screen" id="EN-US_TOPIC_0000001381808753__screen1755661631916">\copy table_name to '/directory_name/file_name';</pre>
|
|
</li><li id="EN-US_TOPIC_0000001381808753__li145885397199">Specify the <strong id="EN-US_TOPIC_0000001381808753__b8541141143912">copy_option</strong> parameter to export data to a CSV file.<pre class="screen" id="EN-US_TOPIC_0000001381808753__screen46282255205">\copy table_name to '/directory_name/file_name' CSV;</pre>
|
|
</li><li id="EN-US_TOPIC_0000001381808753__li1662428197">Use <strong id="EN-US_TOPIC_0000001381808753__b14122161416399">with</strong> to specify parameters, exporting data as CSV files that use vertical bars (|) as delimiters.<pre class="screen" id="EN-US_TOPIC_0000001381808753__screen177732028202012">\copy table_name to '/directory_name/file_name' with(format 'csv',delimiter '|') ;</pre>
|
|
</li></ol>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_03_0026.html">Data Import and Export</a></div>
|
|
</div>
|
|
</div>
|
|
|