Oracle“将表创建为"空值 [英] Oracle "create table as" null value

查看:125
本文介绍了Oracle“将表创建为"空值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您使用其中一个字段为null的创建为"创建Oracle表,则会收到错误消息:

ORA-01723:不允许长度为零的列

查询示例:

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

如何解决这个问题?

解决方案

指出需要使用cast(null as datatype)

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

更多信息此处.

If you create an Oracle table using "create as" where one of your fields is null you will get the error:

ORA-01723: zero-length columns are not allowed

Example query:

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

How can you get around this?

解决方案

Figured it out need to use cast(null as datatype)

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

Some more info here.

这篇关于Oracle“将表创建为"空值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆