I'm using copy to import a csv file into postgres, one of the fields contains a time value in HH:MM:SS formate. I want to be able to set this to a TIMESTAMP field, I've looked through lots of documents but I'm struggling to work out what field type to set it to. I see lots of reference to creating fields with timezones or not, a date etc, not really what I'm after. The ultimate aim is to create reports based on time intervals, e.g. all data between 00:00:00 and 06:30:00 etc
2 Answers
Here is an example:
CREATE TABLE table01
(
rowid bigint NOT NULL,
time_field time without time zone,
CONSTRAINT table01_pkey PRIMARY KEY (rowid)
)
WITH (
OIDS=FALSE
);
And here is an file example:
100,12:30:59
200,08:59:01
You can importe this last file to table01 using copy command like this:
COPY table01 from 'c:/tmp/table01.txt' with csv
Considerning that the file named table01.txt located at : c:/tmp/ folder.
Reference: copy