慎用create table as select,一定要注意默认值的问题
再做一些数据迁移时候,很多人会使用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,一定要注意默认值的问题的更多相关文章
- select into 、 insert into select 、create table as select复制表
Insert是T-sql中常用语句,Insert INTO table(field1,field2,...) values(value1,value2,...)这种形式的在应用程序开发中必不可少.但 ...
- sqlserver不能直接create table as select
sqlserver不能直接create table as select 在sqlserver 下想复制一张表的,想到oracle下直接create table xxx as select * from ...
- 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 ...
- create table 使用select查询语句创建表的方法分享
转自:http://www.maomao365.com/?p=6642 摘要:下文讲述使用select查询语句建立新的数据表的方法分享 ---1 mysql create table `新数据表名` ...
- 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 ...
- 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 ...
- Create table as select
create table xxx as select create table table1 =; 根据table2的表结构,创建tables1 create table table1 as sele ...
- 根据查询结果创建新表create table .. as (select....)
一张表 student 查询数学和英语都是90分以上的同学,并创建一张新表 test1
- 设置select组件中的默认值
会员卡类型 <select id="name2" style="width:140px"> <option value="Ak& ...
随机推荐
- python字典-字典方法
1.kyes() (1)取出字典的key In [32]: myCat Out[32]: {'colr': 'gray', 'size': 'fat'} In [33]: for i in myCat ...
- SpringBoot 使用Mybatis+MySql
pom配置 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http: ...
- [Python3 填坑] 006 “杠零”,空字符的使用
目录 1. print( 坑的信息 ) 2. 开始填坑 2.1 \0 是空字符,输出时看不到它,但它占 1 个字符的长度 2.2 \0 "遇八进制失效" 2.3 \0 与 '' 不 ...
- Ad Hoc Distributed Queries / xp_cmdshell 的启用与关闭
启用Ad Hoc Distributed Queries: reconfigure reconfigure 关闭Ad Hoc Distributed Queries: reconfigure reco ...
- Redis基础都不会,好意思出去面试?
作者:张君鸿 juejin.im/post/5d078cd6f265da1b8466e62c Redis的数据结构 Redis支持多种不同的数据结构,包括5种基础数据结构和几种比较复杂的数据,这些数据 ...
- [ZJOI2009]取石子游戏
瞪了题解两三天,直接下转第二篇题解就康懂了 首先我们令 : \(L[i][j]\) 表示当前 \([i,j]\) 区间左侧放置 \(L[i,j]\) 数量的石子后先手必败 \(R[i][j]\) 表示 ...
- python学习第四十三天生成器和next()关联
我们在用列表生成式的时候,如果有一百万的数据,内存显然不够用,这是python想要什么数据,就生产什么数据给你,就产生了生成器,下面简单讲述生成器用法 1,生成器的用法 a=([a*a for a i ...
- spark sql 操作
DSL风格语法 1.查看DataFrame中的内容 scala> df1.show +---+--------+---+ | id| name|age| +---+--------+---+ | ...
- struts2导入多个xml引入报错<include>
struts.xml <?xml version="1.0" encoding="UTF-8"?> <!-- 指定Struts 2配置文件的D ...
- JVM Heap Memory和Native Memory
JVM管理的内存可以总体划分为两部分:Heap Memory和Native Memory.前者我们比较熟悉,是供Java应用程序使用的:后者也称为C-Heap,是供JVM自身进程使用的.Heap Me ...