再做一些数据迁移时候,很多人会使用create table  as select * from table where id=-1的方式来年建立一摸一样的表,但是这样做有个很大的弊端,不能将原表中的default value也一同迁移过来,可以看下面的例子:

第一,新建一个表

-- Create table create table table01 (   id        number(16),   add_date  date default sysdate,   status    number(1),   entp_code varchar2(200) )

第二,使用create table table02 as select * From table01 where id=-1

第三、看看两个表的结构,会发现第二张表的defaule value没有了,如下2图,可以很明显看出来,表02的add_date的默认值得sysdate没有了

table01的表结构

table02的表结构

所以各位在做数据库迁移时候,使用create table as select时候,一定要注意默认值的问题

转自【http://wmcxy.iteye.com/blog/1137179

慎用create table as select,一定要注意默认值的问题的更多相关文章

  1. select into 、 insert into select 、create table as select复制表

    Insert是T-sql中常用语句,Insert INTO table(field1,field2,...)  values(value1,value2,...)这种形式的在应用程序开发中必不可少.但 ...

  2. sqlserver不能直接create table as select

    sqlserver不能直接create table as select 在sqlserver 下想复制一张表的,想到oracle下直接create table xxx as select * from ...

  3. oracle数据库【表复制】insert into select from跟create table as select * from 两种表复制语句区别

    create table  as select * from和insert into select from两种表复制语句区别 create table targer_table as select ...

  4. create table 使用select查询语句创建表的方法分享

    转自:http://www.maomao365.com/?p=6642 摘要:下文讲述使用select查询语句建立新的数据表的方法分享 ---1 mysql create table `新数据表名` ...

  5. MySQL中表复制:create table like 与 create table as select

    CREATE TABLE A LIKE B 此种方式在将表B复制到A时候会将表B完整的字段结构和索引复制到表A中来. CREATE TABLE A AS SELECT x,x,x,xx FROM B ...

  6. MySQL中表复制:create table like 与 create table as select

    1    CREATE TABLE A LIKE B此种方式在将表B复制到A时候会将表B完整的字段结构和索引复制到表A中来. 2.    CREATE TABLE A AS SELECT * FROM ...

  7. Create table as select

    create table xxx as select create table table1 =; 根据table2的表结构,创建tables1 create table table1 as sele ...

  8. 根据查询结果创建新表create table .. as (select....)

    一张表 student 查询数学和英语都是90分以上的同学,并创建一张新表 test1

  9. 设置select组件中的默认值

    会员卡类型   <select id="name2" style="width:140px"> <option value="Ak& ...

随机推荐

  1. Maven 标准项目结构

    项目结构 src main java         源文件 resources    资源文件 filters   资源过滤文件 config   配置文件 scripts   脚本文件 webap ...

  2. 阿里大佬教你,如何写好 Java 代码!

    点击上方蓝色链接,关注并"设为星标" Java干货,每天及时推送 阿里大佬分享的一篇很不错的文章,推荐收藏! 导读 明代王阳明先生在<传习录>谈为学之道时说: 私欲日生 ...

  3. 第7章 PTA查找练习题

    这道题与第7章查找有关,当时提前看到,翻到书里面的算法,然后打进去,虽然是正确的,但是那时候并不知道二叉排序树的基础知识,包括插入查找的来龙去脉,现在已经学到了,有了一定了解,发现题目只用到了其中部分 ...

  4. 又一年NOIP后的一波总结

    (昨天正式考完了吧...先写一下现在的感受,出成绩以及后续继续更...) 按照国际惯例,还是先讲一下故事吧. Day(~,0] 大概是跟随者时间的推进,气氛越来越紧张吧. 平时好像大家和往常一样,日常 ...

  5. Echarts数据可视化grid直角坐标系(xAxis、yAxis)详解:

    mytextStyle={ color:"#333", //文字颜色 fontStyle:"normal", //italic斜体 oblique倾斜 font ...

  6. 实现斐波那契数列之es5、es6

    es5实现斐波拉契函数数列: <script type="text/javascript"> function fibonacci(n) { var one = 1; ...

  7. linux grep 设置高亮显示

    [root@eric ~]# vi /etc/profile alias grep='grep --color=auto' [root@eric ~]# source /etc/profile

  8. nginx多层反代配置变量proxy_set_header

    Nginx多层反代配置变量proxy_set_header过程记录 第一层代理: (1)路径: $ vim /data/soft/nginx/conf/vhost/xixi.conf (2)内容:(注 ...

  9. static作用,静态成员变量和静态成员函数

    static关键字有俩作用:(1).控制存储分配:(2).控制一个名字的可见性和连接.   随着C++名字空间的引入,我们有了更好的,更灵活的方法来控制一个大项目的名字增长.     在类的内部使用s ...

  10. 【串线篇】spring boot自动配置精髓

    一.SpringBoot启动会加载大量的自动配置类即绿色部分 二.我们看我们需要的功能有没有SpringBoot默认写好的自动配置类: 比如HttpEncodingAutoConfiguration ...