Oracle 中create table as 复制表结构

Oracle 中create table as 复制表结构

在日常测试或者数据迁移的过程中,经常使用create table as …复制表结构或者复制表结构和数据,用法如下:

复制表结构:create table tab_target as select * from table where 1=0
复制表结构保留数据:create table tab_target as select * from table where 1=1
但是在迁移的过程要注意约束和默认值的情况,测试过程如下:
在这里插入图片描述
利用上述代码建立一个源表和源表的copy表,之后在plsql中查表的建表语句,如下:在这里插入图片描述
在这里插入图片描述
可以发现 通过create table …as …建的表含有 not null 这个约束条件,但是指定默认值的条件没有了

猜你喜欢

转载自blog.csdn.net/weixin_40417658/article/details/85060427
今日推荐