Search
 
SCRIPT & CODE EXAMPLE
 

SQL

PostgreSQL to a CSV file

-- Client side -This approach does the file handling on the client side
Copy (Select * From foo) To '/tmp/test.csv' With CSV DELIMITER ',' HEADER

-- Server side - This approach runs entirely on the remote server
Copy (Select * From foo) To '/tmp/test.csv' With CSV DELIMITER ',' HEADER;
Comment

postgres select as csv

-- To stdout
COPY (select * from table) TO STDOUT WITH CSV HEADER;

-- To file
COPY (select * from table) TO '/table.csv' WITH CSV HEADER;
Comment

csv into data postgres

COPY table_name FROM 'C:UsersPublicDocumentsert.txt' DELIMITER ',' CSV
-- make sure to put the file in public folder in windows 
-- Or temp folder in linux/mac 
-- because it might ask for some permissions...
Comment

postgresql import data from csv

copy table from '/home/usama/Documents/columns_rearrange.csv' csv header ;
Comment

Import CSV to PostgreSQL

COPY mytable FROM '/path/to/csv/file' WITH CSV HEADER; -- must be superuser
Comment

PREVIOUS NEXT
Code Example
Sql :: sql default value if null 
Sql :: psql check if value in array 
Sql :: oracle lock user 
Sql :: mysql grant user permissions 
Sql :: on sql table data exists 
Sql :: sql dcl 
Sql :: sql pivot without aggregate 
Sql :: SELECT DISTINCT on one column, with multiple columns returned, ms access query 
Sql :: sql server check for value in multiple columns 
Sql :: sqrt(i) 
Sql :: mysql switch case 
Sql :: power query datetime to date 
Sql :: how to find max and min salary in sql 
Sql :: order by sql query 
Sql :: SQL Server run query on linked server 
Sql :: How to check if a column exists in a SQL Server table? 
Sql :: control files oracle 
Sql :: postgresql variable in query 
Sql :: mysql sort asc numeric 
Sql :: convert minutes to hours sql 
Sql :: if sql 
Sql :: sql select like 
Sql :: get last record deluge 
Sql :: if role exists sql 
Sql :: psql command not found windows 
Sql :: how to login to mysql in homestead 
Sql :: xml to column sql 
Sql :: microsoft sql server management studio uppercase shortcut 
Sql :: oracle convert hours to minutes 
Sql :: Create parameterized VIEW in SQL Server 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =