简体   繁体   中英

Is there any efficient way to select all from one table and insert in another

I need help with PHP PDO and SQLITE3. I have table device like

CREATE TABLE device (
 object_identifier integer PRIMARY KEY NOT NULL,
 object_name varchar(1024),
 vendor_name varchar(1024),
 vendor_identifier integer,
 model_name varchar(1024),
 firmware_revision varchar(1024),
 application_software_version varchar(1024),
 protocol_version integer,
 protocol_revision integer,
 max_apdu_length_accepted integer,
 apdu_timeout integer,
 number_of_apdu_retries integer,
 database_revision integer,
 system_status integer,
 protocol_object_types_supported varchar(65),
 segmentation_supported integer,
 protocol_services_supported varchar(65),
 local_time varchar(32),
 local_date varchar(32),
 location varchar(1024),
 object_list_num integer
);

and I have another table fan_coil_jebeni like

CREATE TABLE fan_coil_jebeni (
 object_identifier integer PRIMARY KEY NOT NULL,
 object_name varchar(1024),
 vendor_name varchar(1024),
);

My question is there any efficient way to select all from device and insert into fan_coil_jebeni without iterative comming through cursor ( there is a bunch of rows to beinserted ) ?

您可以使用插入...选择

insert into fan_coil_jebeni(a,b,c) select a,b,c from device

这个怎么样:

INSERT INTO fan_coil_jebeni SELECT object_identifier, object_name, vendor_name FROM device;
CREATE TABLE IF NOT EXISTS `table1` SELECT * FROM `table2`

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM