With a question like that you should always include information about your operating system and version number of PostgreSQL.
Your statement is suspicious:
COPY data FROM 'data.dat' USING DELIMITERS ',' CSV;
DELIMITERS
was used in versions before 7.3. It is still supported in order not to break old code, but don't use it any more. The proper keyword is DELIMITER
. And you don't need to specify ,
at all as it is the default for FORMAT CSV
.
Also, I quote the manual here:
filename
The absolute path name of the input or output file. Windows users might need to use an E'' string and double any backslashes used in the
path name.
So, your 'data.dat'
should be something like '/path/to/data.dat'
on UNIX or E'C:\\path\\to\\data.dat'
on Windows.
For versions 7.3+ use:
COPY data FROM '/path/to/data.dat' CSV
For versions 9.0+ use:
COPY data FROM '/path/to/data.dat' (FORMAT CSV)
If you still get this error:
ERROR: invalid input syntax for type numeric: CONTEXT: COPY data, line 13, column interval_2400:
Then, obviously, the source file does not match the structure of table data
. Have a look at your source file, go to line 13 and see what value is there for column interval_2400
. Chances are, it's not numeric. You can either fix the source file or adapt the table definition:
ALTER TABLE data ALTER COLUMN interval_2400 TYPE text;
Or what ever type is more appropriate. Might be interval
, judging from the name.