我只想在Postgres的同一个DB中从schema1复制4个表到schema2.我也想把这些表也保留在schema1中.你知道如何在pgadmin和postgres控制台上做到这一点吗?

推荐答案

你可以用create table ... like

create table schema2.the_table (like schema1.the_table including all);

然后将数据从源插入目标:

insert into schema2.the_table
select * 
from schema1.the_table;

Postgresql相关问答推荐

如何在gorm中创建一个可读但不可写的字段

如何获得一起满足数量要求的物品? (WHILE 循环还是 CTE?)postgresql

Select 与输入数组完全相交的所有行?

如何准确确定边界附近的点和地理的 ST_Intersects(ST_Intersects geography vs. Geometry diffrepancy)

需要用 jack/pgx 更新 golang 中复合类型的 PSQL 行

在 PostgreSQL 中 Select 数字命名列会返回 ?column?

Postgis 不只使用索引扫描

在 PostgreSQL 中将时间转换为秒

statement_date列是日期类型,但表达式是整数类型

org.postgresql.util.PSQLException:错误:relation "app_user" does not exist

如何在构建时链接 docker 容器?

使用 postgres regexp_replace 将字符串列表替换为始终相同的字符串

如何将两个 PostgreSQL 列聚合到一个用括号分隔的数组

如何在数据库表中查找重复条目?

Django 1.9.2 AssertionError:database connection isn't set to UTC

仅在存在时重命名列

PostgreSQL 获取过go 12 小时的元素

Postgres Hstore 与 Redis - 性能方面

PostgreSQL 9 在 Windows 上安装:Unable to write inside TEMP environment path.

PostgreSQL:如果不存在则创建表 AS