CSV Import - Set table column to fixed value

已回答

I'm trying to import a CSV file to an existing Oracle (v19c) table and I want to set a couple of columns to fixed values like:

  • “some string”
  • SYSDATE (Oracle pseudo-function for the current date/time)

The first row of the CSV file has the column names, and I've checked that option in DataGrip.

Then I edited the table column mapping, replacing the pre-selected CSV column name with the fixed value.

Datagrip loads the records, and reports no errors, but the table column value is always NULL.

I've tried surrounding the string value with nothing, single quotes (Oracle's standard) and double quotes. But the result is always the same; the table column is NULL.

And trying to use the SYSDATE function in a date field causes DataGrip to raise a system error, without saving any rows.

Is this possible, or does the CSV file layout have to match the database table definition exactly?

0

Hello,

Could you please clarify if you need to insert values from CSV file or create table from CSV file?

0

I'm not sure if I understand your question. The first sentence of my post was:

> I'm trying to import a CSV file to an existing Oracle (v19c) table.

So I'm loading new records from the CSV file into a current table (without changing they table's definition). I want to set just a couple table columns with fixed values using either constant strings or Oracle functions (SYSDATE).

Thanks for your help.

0

You said “replacing the pre-selected CSV column name with the fixed value”. Could you please attach screenshot demonstrating it? If you change column name in mapping it doesn't change the values. If you need to insert some values, you may change them in CSV file.

0

Yaroslav Bedrov I just replied to your support email.

I thought I could simply change the mapping. It seems overly-burdensome to update the source CSV file since the column value will be a constant.

For others, this is what I'm trying to do:

https://www.dropbox.com/scl/fi/chm6e8y94bz556skji8jn/DataGrip-Import-from-File.jpg?rlkey=94a4ns68iecebx5jcqwstge7d&dl=0

0

If anyone's interested, Yaroslav's answer was: 

But mapping is about column mapping, not about values. It just says from which column in CSV file it should take data and into which it should be placed. Because you may have different namings in CSV file and DB table.

My response was:

  1. “It seems very limiting to expect that the CSV file columns will map one-to-one to database table column.”
  2. I asked him to submit this as a DataGrip enhancement request, since competitors' tools support this feature.
0

请先登录再写评论。