随笔 - 237  文章 - 0  评论 - 7  阅读 - 21万

Oracle 复制表

oracle中复制表结构和表数据:

1、复制表结构及数据:

create table new_table as select * from old_table

2、只复制表结构:

create table new_table as select * from old_table where 1<>1

3、复制表的指定字段:

create table new_table as select column1,column2… from old_table where 1<>1 (前提是column1…是old_table的列)

4、复制表的指定字段及数据:

create table new_table as select column1,column2… from old_table where(前提是column1…是old_table的列)

5、在已存在的表中插入数据:

A.两个表结构一样

insert into new_table select * from old_table (前提是必须要有一个new_table 表才能查数据)

B.表结构不一样:

insert into new_table (column1,column2…) select column1,column2… from old_table (注意:两个表中的要复制的列数据类型和长度最好要一致,要注意长度大小问题)

以上语句能根据已有的表来创建新表及数据,但是已有表的索引却复制不了,需要在新表中手动建立,而且注释什么的都不会被复制过来的。

posted on   洞幺人生  阅读(2710)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示