Oracle从另一个表中插入所有数据,其中一列为null

时间:2015-11-26 07:41:33

标签: oracle oracle11g oracle10g

我有两个表A和B两个相同的结构,除了B有一个额外的列。我需要保留B中A的所有数据,但额外列应设置为null。这该怎么做。请帮忙。

Table A:
    id VARCHAR2(64) NOT NULL, 
    effectiveDate DATE, 
    endDate DATE, 
    startDate DATE, 
    Type NUMBER(9), 
    salary NUMBER(19,3), 
    baseSalary NUMBER(19,3), 
    Amount NUMBER(19,3), 
    Amount1 NUMBER(19,3), 
    currency NUMBER(9), 
    Percentage NUMBER(20,9), 
    Salary NUMBER(19,3) 


Table B

 id VARCHAR2(64) NOT NULL, 
    effectiveDate DATE, 
    endDate DATE, 
    startDate DATE, 
    Type NUMBER(9), 
    salary NUMBER(19,3), 
    baseSalary NUMBER(19,3), 
    Amount NUMBER(19,3), 
    Amount1 NUMBER(19,3), 
    currency NUMBER(9), 
    Percentage NUMBER(20,9), 
    Salary NUMBER(19,3),
    Notional NUMBER(9) -- This is the new column need to set as null

提前致谢。

1 个答案:

答案 0 :(得分:0)

insert
  into tableB(
         id,          effectiveDate, endDate
        ,startDate,   Type,          salary
        ,baseSalary,  Amount,        Amount1
        ,currency,    Percentage,    Salary
        ,Notional
       )
select   id,          effectiveDate, endDate
        ,startDate,   Type,          salary
        ,baseSalary,  Amount,        Amount1
        ,currency,    Percentage,    Salary
        ,null
  from tableA;