Oracle"创建表格为"空值

时间:2016-05-24 15:09:26

标签: oracle

如果使用&#34创建Oracle表,则创建为"如果您的某个字段为null,则会收到错误:

  

ORA-01723:不允许零长度列

示例查询:

create table mytable as 
select 
    field_a, 
    null brand_new_field
from anothertable;

你怎么能绕过这个?

2 个答案:

答案 0 :(得分:5)

想出它需要使用cast(null as datatype)

create table mytable as 
select 
    field_a, 
    cast(null as varchar(1)) brand_new_field
from anothertable;

更多信息here

答案 1 :(得分:0)

这是如何解决它的方法之一。

create table mytable as 
select 
    field_a, 
    ' ' brand_new_field
from anothertable;
相关问题