如何制作带有PK的表的副本? [英] How can I make a copy of a table with a PK?

查看:54
本文介绍了如何制作带有PK的表的副本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Oracle 10g数据库中,我想复制一个现有表.我希望它具有与原始表相同的数据和行.尽管原始表使用的是PK,所以我不确定如何复制它并使它们保持唯一.

In an Oracle 10g database, I would like to make a copy of an existing table. I would like it to have the same data and rows as the original table. The original table uses a PK though, so I'm not sure how to copy it and keep them unique.

推荐答案

您可以使用

CREATE TABLE dummy_copy as SELECT * FROM dummy//Structure and data

还可以使用 dbms_metadata.get_ddl 获取表的关联约束 并用所有支票创建它

Also you could use dbms_metadata.get_ddl to get the associated constraints of the table and create it with all the checks

 SELECT dbms_metadata.get_ddl( 'TABLE', 'dummy' ) FROM DUAL;

这篇关于如何制作带有PK的表的副本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆