Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create Table from View - Oracle SQL SQL Error: ORA-01723: zero-length columns are not allowed

Tags:

sql

oracle

I need to create a table from view with statement like

CREATE  TABLE NEW_TABLE AS
    SELECT *
    from VIEW

It is giving error message as below. It is not possible to create table from view (with Select * statement)?

Error report -
SQL Error: ORA-01723: zero-length columns are not allowed
01723. 00000 -  "zero-length columns are not allowed
like image 756
mahesh Avatar asked Aug 12 '17 15:08

mahesh


1 Answers

I have this problem when NULL is specified for a column, but the type is not specified. Arrgh!

You will need to look at the code. This often happens when I use:

select '' as x

Because I think '' should have the right type.

In any case, the solution is simple:

select cast(NULL as varchar2(255)),
       cast(NULL as number)

or whatever the type is.

You'll need to either change the view definition, or use a query with a subquery with explicit casts.

like image 125
Gordon Linoff Avatar answered Oct 16 '22 08:10

Gordon Linoff