Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql ORA:01467排序键太长_Sql_Oracle - Fatal编程技术网

Sql ORA:01467排序键太长

Sql ORA:01467排序键太长,sql,oracle,Sql,Oracle,我试图通过结合studenthistory和student表来找到行的原始值。 我必须创建动态查询,在运行时从具有不同模式的学生表中选择列。 当我使用90多列执行下面的查询时,它给出了错误“ORA-01467” 这是Oracle中已知的限制 根据Oracle文档,ORA-01467的原因和解决方案如下 原因:不同、分组依据、排序依据或集合操作需要 排序键的长度超过Oracle支持的长度。或者列太多 或者在SELECT语句中指定了太多的组函数 操作:减少操作中涉及的列数或组函数数 手术 查询中有9

我试图通过结合studenthistory和student表来找到行的原始值。 我必须创建动态查询,在运行时从具有不同模式的学生表中选择列。 当我使用90多列执行下面的查询时,它给出了错误“ORA-01467”


这是Oracle中已知的限制

根据Oracle文档,ORA-01467的原因和解决方案如下

原因:不同、分组依据、排序依据或集合操作需要 排序键的长度超过Oracle支持的长度。或者列太多 或者在SELECT语句中指定了太多的组函数

操作:减少操作中涉及的列数或组函数数 手术

查询中有90列可能超过数据库的块大小

除了减少列数以便这些列的数据必须适合单个块之外,没有解决此问题的方法


干杯

您好@Purva,您有两个相同的查询和两个不同的问题??这回答了你的问题吗?另一方面,您的数据库或查询是错误的。student history表应该有一个student ID,联接必须使用它:
on s.ID=sh.student\u ID
。如果
studenthistory.id
实际上是学生id,那么应该这样命名。如果不是,则表示您加入了错误的列。这是一个复杂的查询。它表明student表只包含初始数据,student history表包含此后的所有单个更改,其中更改的列被设置,其他列为空。您的查询应该显示学生更改历史记录中每天的完整学生数据,直到最后一个代表当前数据的条目。在我看来,最好是保留学生表当前数据和历史记录表,只有当您想查看某个特定值的设置时间时,才会查看。更正:对于每个更改日期,您都会显示以前的值。因此,初始数据显示两次;当前数据根本不显示。

select sh.id,
       coalesce(sh.name,
                lag(sh.name ignore nulls) over (partition by sh.id order by sh.DatetimeCreated),
                s.name
               ) as name,
       coalesce(sh.city,
                lag(sh.city ignore nulls) over (partition by sh.id order by sh.DatetimeCreated),
                s.city
               ) as city,
       coalesce(sh.address,
                lag(sh.address ignore nulls) over (partition by sh.id order by sh.DatetimeCreated),
                s.address
               ) as address,
        s.createdDateTime,
        sh.createdDateTime as updatedDateTime,
Coalesce(sh.column1, lag(sh.column1)over(partition by sh.id order by sh.DatetimeCreated desc), s.column1) as column1,
from studenthistory sh join
     student s
     on s.id = sh.id
union all
select s.id, s.name, s.city, s.address, s.createdDateTime, s.updatedDateTime
from student s;