更新时间:2022-12-11 23:21:59
你不能轻易做到这一点,但也没有必要这样做.
You cannot easily do that, but there's also no need to do so.
CREATE TABLE mycopy AS
SELECT * FROM mytable;
或
CREATE TABLE mycopy (LIKE mytable INCLUDING ALL);
INSERT INTO mycopy
SELECT * FROM mytable;
如果您只需要选择某些列或对它们重新排序,您可以这样做:
If you need to select only some columns or reorder them, you can do this:
INSERT INTO mycopy(colA, colB)
SELECT col1, col2 FROM mytable;
您还可以选择性地执行 pg_dump 并恢复目标表.
You can also do a selective pg_dump and restore of just the target table.