Se ho capito bene la tua domanda, si poteva leggere la singola stringa (s) in una tabella temporanea e l'uso che per l'inserimento:
DROP SCHEMA str CASCADE;
CREATE SCHEMA str;
SET search_path='str';
CREATE TABLE strings
(string_id INTEGER PRIMARY KEY
, the_string varchar
);
CREATE TEMP TABLE string_only
(the_string varchar
);
COPY string_only(the_string)
FROM '/tmp/string'
;
INSERT INTO strings(string_id,the_string)
SELECT 5, t.the_string
FROM string_only t
;
SELECT * FROM strings;
Risultato:
NOTICE: drop cascades to table str.strings
DROP SCHEMA
CREATE SCHEMA
SET
NOTICE: CREATE TABLE/PRIMARY KEY will create implicit index "strings_pkey" for table "strings"
CREATE TABLE
CREATE TABLE
COPY 1
INSERT 0 1
string_id | the_string
-----------+---------------------
5 | this is the content
(1 row)
Si prega di notare che la il file viene "visto" dal server mentre il server vede il filesystem. La "directory corrente" da quel punto di vista è probabilmente $ PG_DATA, ma non dovresti assumere nulla e specificare il percorso completo, che dovrebbe essere raggiungibile e leggibile dal dal server. Questo è il motivo per cui ho usato "/ tmp", che non è sicuro (ma un eccellente punto di rendez-vous ;-)
si suppone che il file per contenere solo una riga = row = colonna = campo? – wildplasser
Sì, il file contiene solo una riga, che non contiene nient'altro che quella stringa. – user905747
Ok, vedere potrebbe rispondere. (Ho indovinato) – wildplasser