ITPub博客

首页 > 数据库 > Oracle > [20241012]ORA-01792 maximum number of columns in a table or view is 1000.txt

[20241012]ORA-01792 maximum number of columns in a table or view is 1000.txt

原创 Oracle 作者:lfree 时间:2024-10-12 20:23:15 0 删除 编辑

[20241012]ORA-01792 maximum number of columns in a table or view is 1000.txt

--//12c数据库查询遇到的问题,几个大型视图,字段很多连接时出现问题。
ORA-01792: maximum number of columns in a table or view is 1000

--//上网查询以后发现设置alter session set "_fix_control"='17376322:OFF';可以解决。

SCOTT@book01p> column SESSION_ID format 9999999999
SCOTT@book01p> column event format 999999999
SCOTT@book01p> @ fix "1000 columns"
SCOTT@book01p> @ pr
==============================
SESSION_ID                    : 18
BUGNO                         : 17376322
VALUE                         : 0
SQL_FEATURE                   : QKSFM_CBO_17376322
DESCRIPTION                   : raise error if view(s) have more than 1000 columns
OPTIMIZER_FEATURE_ENABLE      :
EVENT                         : 0
IS_DEFAULT                    : 1
CON_ID                        : 3
PL/SQL procedure successfully completed.
--//21c IS_DEFAULT=1 对应是off。

--//简单演示:

1.环境:
SCOTT@book01p> @ver2
==============================
PORT_STRING                   : x86_64/Linux 2.4.xx
VERSION                       : 21.0.0.0.0
BANNER                        : Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production
BANNER_FULL                   : Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0
BANNER_LEGACY                 : Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production
CON_ID                        : 0
PL/SQL procedure successfully completed.

$ cat ct.txt
set head off feedback off
spool a.txt
select 'create table t1 (' from dual
union all
select 'col'||lpad(rownum-1,3,'0')||' number(1),' from dual connect by level<=400
union all
select 'constraint t1_pk primary key (col000));' from dual ;
spool off
set head on feedback 6
--//适当改名,建立3个表t1,t2,t3,每个表400字段,过程略,分析表略。

2.测试:

SCOTT@book01p> alter session set "_fix_control"='17376322:ON';
Session altered.

SCOTT@book01p> @ fix "1000 columns"
SCOTT@book01p> @ pr
==============================
SESSION_ID                    : 18
BUGNO                         : 17376322
VALUE                         : 0
SQL_FEATURE                   : QKSFM_CBO_17376322
DESCRIPTION                   : raise error if view(s) have more than 1000 columns
OPTIMIZER_FEATURE_ENABLE      :
EVENT                         : 0
IS_DEFAULT                    : 0
CON_ID                        : 3
PL/SQL procedure successfully completed.

SCOTT@book01p> select t3.* from t1 join t2 on (t1.col000 = t2.col000) join t3 on (t2.col000 = t3.col000);
select t3.* from t1 join t2 on (t1.col000 = t2.col000) join t3 on (t2.col000 = t3.col000)
                                                            *
ERROR at line 1:
ORA-01792: maximum number of columns in a table or view is 1000
--//这样情况即使输出1个表t3也报错,如果使用非ansi连接写法不报错。

SCOTT@book01p> select t3.* from t1 ,t2,t3 where t1.col000 = t2.col000 and t2.col000 = t3.col000;
no rows selected

SCOTT@book01p> select * from t1 ,t2,t3 where t1.col000 = t2.col000 and t2.col000 = t3.col000;
no rows selected

SCOTT@book01p> alter session set "_fix_control"='17376322:OFF';
Session altered.

SCOTT@book01p> @ fix "1000 columns"
SCOTT@book01p> @ pr
==============================
SESSION_ID                    : 18
BUGNO                         : 17376322
VALUE                         : 0
SQL_FEATURE                   : QKSFM_CBO_17376322
DESCRIPTION                   : raise error if view(s) have more than 1000 columns
OPTIMIZER_FEATURE_ENABLE      :
EVENT                         : 0
IS_DEFAULT                    : 1
CON_ID                        : 3
PL/SQL procedure successfully completed.
--//IS_DEFAULT=1

SCOTT@book01p> select t3.* from t1 join t2 on (t1.col000 = t2.col000) join t3 on (t2.col000 = t3.col000);
no rows selected

SCOTT@book01p> select * from t1 join t2 on (t1.col000 = t2.col000) join t3 on (t2.col000 = t3.col000);
no rows selected
--//3个表一起输出也没有问题。

SCOTT@book01p> select * from t1 ,t2,t3 where t1.col000 = t2.col000 and t2.col000 = t3.col000;
no rows selected

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/267265/viewspace-3038094/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。

注册时间:2008-01-03

  • 博文量
    4006
  • 访问量
    7969784