Is there any way to copy entire data from one table to another table?
Condition: without making these data to retrieve from one table and storing to array than saving to another table.
Reason according to me:
To copy data from one table and also all the dependent objects of the table, you use the following statements:
CREATE TABLE IF NOT EXISTS new_table LIKE existing_table;
INSERT new_table
SELECT * FROM existing_table;
From here: MySQL Copy Table With Examples
$results = DB::select( DB::raw("CREATE TABLE tbl_new AS SELECT * FROM tbl_old;'") );
I believe you will get what you want.
comment on this answer if you need more info
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.