次の最終ステートメントを単純化しようとしています。
DROP TABLE asdf;
CREATE TABLE asdf (LIKE calibrations);
INSERT INTO asdf (rid, pid, status, cal_date, project_name, username,
sensor_type, serial_number, var_name, dsm_name, cal_type, channel,
gainbplr, ads_file_name, set_times, set_points, averages, stddevs, cal,
temperature, comment)
SELECT * FROM dblink(
'host=remoteserv user=auser password=hello dbname=cals',
'SELECT * FROM calibrations WHERE username=\'JAM\'') AS
t(rid character varying(20), pid character varying(20),
status character(3), cal_date timestamp,
project_name character varying(32), username character varying(32),
sensor_type character varying(20), sn character varying(20),
var_name character varying(20), dsm_name character varying(16),
cal_type character varying(16), channel character(1),
gainbplr character(2), ads_file_name character varying(40),
set_times timestamp[], set_points double precision[],
averages double precision[], stddevs double precision[],
cal double precision[], temperature double precision,
comment character varying(256));
最後のステートメントを次のように単純化できました。
INSERT INTO asdf
SELECT * FROM dblink(
'host=remoteserv user=auser password=hello dbname=cals',
'SELECT * FROM calibrations WHERE username=\'JAM\'') AS
t(rid character varying(20), pid character varying(20),
status character(3), cal_date timestamp,
project_name character varying(32), username character varying(32),
sensor_type character varying(20), sn character varying(20),
var_name character varying(20), dsm_name character varying(16),
cal_type character varying(16), channel character(1),
gainbplr character(2), ads_file_name character varying(40),
set_times timestamp[], set_points double precision[],
averages double precision[], stddevs double precision[],
cal double precision[], temperature double precision,
comment character varying(256));
最後のステートメントをこのように書くことは可能ですか?
INSERT INTO asdf
SELECT * FROM dblink(
'host=remoteserv user=auser password=hello dbname=cals',
'SELECT * FROM calibrations WHERE username=\'JAM\'') AS
t(LIKE calibrations);
-- ジョン