MAN*_*ANU 11 postgresql pgadmin
我想在Postgres中的同一个DB中只将4个表从schema1复制到schema2.并且希望将表保留在schema1中.知道如何在pgadmin和postgres控制台中做到这一点?
a_h*_*ame 39
您可以使用 create table ... like
create table schema2.the_table (like schema1.the_table including all);
Run Code Online (Sandbox Code Playgroud)
然后将数据从源插入到目标:
insert into schema2.the_table
select *
from schema1.the_table;
Run Code Online (Sandbox Code Playgroud)
小智 23
您可以使用CREATE TABLE AS SELECT.这种方式您不需要插入.将使用数据创建表.
CREATE TABLE schema2.the_table
AS
SELECT * FROM schema1.the_table;
Run Code Online (Sandbox Code Playgroud)
从 v12 开始使用的简单语法:
CREATE TABLE newSchema.newTable
AS TABLE oldSchema.oldTable;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
20154 次 |
| 最近记录: |