あなたの質問を正しく理解できれば、単一の文字列を一時テーブルに読み込み、それを挿入に使用できます。
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;
結果:
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)
サーバーがファイルシステムを認識しているため、ファイルはサーバーによって「認識」されていることに注意してください。その観点からの「現在のディレクトリ」はおそらく $PG_DATA ですが、何も想定せず、サーバーが到達可能で読み取り可能な完全なパス名を指定する必要があります。そのため、安全ではない「/tmp」を使用しました (ただし、ランデブーポイントとしては優れています ;-)