DBA Hub

📋Steps in this guide1/1

export table data to file using COPY

-- export specific column data to text file:

postgresql configurationintermediate
by PostgreSQL
15 views
1

export table data to file using COPY

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
-- export specific column data to text file:
copy EMPLOYEE( EMP_NAME,EMP_ID) to '/tmp/emp.txt';
-- export complete table data to text file:
copy EMPLOYEE to '/tmp/emp.txt';
-- export table data to csv file:
copy EMPLOYEE to '/tmp/emp.csv' with csv headers;
-- export specific query output to csv file:
copy ( select ename,depname from emp where depname='HR') to '/tmp/emp.csv' with csv headers;

Comments (0)

Please to add comments

No comments yet. Be the first to comment!