我正在尝试简化以下最终陈述:
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);
- 约翰