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 开发者_如何学Cvarchar(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 ) ?
you can use insert ... select
insert into fan_coil_jebeni(a,b,c) select a,b,c from device
How about this:
INSERT INTO fan_coil_jebeni SELECT object_identifier, object_name, vendor_name FROM device;
CREATE TABLE IF NOT EXISTS `table1` SELECT * FROM `table2`
精彩评论