Thank you Farjad,
following your suggestion I'm now able to import my csv and the serial automatically is inserted in the new records. Bye E. From: farjad.farid@xxxxxxxxxxxxxxxxx To: frippe12573@xxxxxxxxxxx; pgsql-general@xxxxxxxxxxxxxx Subject: RE: csv import error Date: Tue, 23 Sep 2014 13:38:27 +0100 Hi Eugenio,
How you got about resolving this depends on your project, the size of data. For a simple case, which this seems to be. Simply don’t insert the serial column. E.g. remove both name of the column and its corresponding value in the insert statement. Postgresql will insert these automatically.
If the size of the data is larger or there are dependencies on the OID value elsewhere in the DB then recreated the target table but without making the column ‘serial’. But actually creating all columns. And inserting all column values.
Once the operation is done. Then manually create serial sequencer and attach it to the OID column.
The disadvantage of this is in error detection and correction of the process. If there are errors in CSV files ,which often are as sometimes they are edited manually, then it will be more time consuming to correct. Depending on the size of data in CSV file.
Hope this helps.
Best Regards
Farjad Farid
From: pgsql-general-owner@xxxxxxxxxxxxxx [mailto:pgsql-general-owner@xxxxxxxxxxxxxx] On Behalf Of Eugenio Trumpy
Hi, From: farjad.farid@xxxxxxxxxxxxxxxxx
Hi,
Quotation marks should be around both the name of each and every column and their values.
As the columns names are all lower case. You may wish to remove all quotation marks which is much easier. But character value needs quotation mark.
Also replace the semi-column as column separation character with commas for sql insert statement. What has happened here is that the values from CSV are directly inserted into sql. It needs a little bit of extra work. Hope this helps.
Best Regards
Farjad Farid
From: pgsql-general-owner@xxxxxxxxxxxxxx [mailto:pgsql-general-owner@xxxxxxxxxxxxxx] On Behalf Of Eugenio Trumpy
Hello, LINE 1: INSERT INTO "info_pozzi_hydrocarbon"."assorb" ("key;daprof;a... ^ In statement:
1001334;19.1;21;A;6;;;11 1001334;93.5;94;A;30;;;11 1001334;94;115;A;20;;;11 1001334;154.5;255;A;644;;;11 1001334;273;282;A;4;;;11 1001334;298;309;A;7;;;11 1001334;432;1224;P;1850;;;11 4277001;121;901;A;397;ALLARGAMENTO FORO;;11 4277001;121;901;A;96;PERFORAZIONE;;11 |