[英]Laravel 5.4 - copy data from one table to another table, in same database
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 从这里: MySQL复制表与示例
$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 如果您需要更多信息,请对此答案发表评论
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.