How to copy table between two models in Mysql work

2019-02-08 00:49发布

I am doing some databese thing, I need copy one table from one model to another, but i try many ways there no effect. Is there any way for doing this?

7条回答
时光不老,我们不散
2楼-- · 2019-02-08 01:32

You can just use a select statement. Here I am creating a duplicate of "original_table" table from the "original_schema" schema/database to the "new_schema" schema :

CREATE TABLE new_schema.duplicate_table AS
Select * from original_schema.original_table;

You can just put any select statement you need ,add a condition and select the columns :

CREATE TABLE new_schema.duplicate_table AS
SELECT column1, column2       
FROM original_schema.original_table
WHERE column2 < 11000000;
查看更多
登录 后发表回答