ORA-01791: not a SELECTed expression 一個不是 bug 的 bug!
[[email protected] ~]$ !sql
sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Wed Aug 27 09:50:54 2014
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select distinct sal, empno from scott.emp order by deptno;
SAL EMPNO
---------- ----------
2450 7782
5000 7839
1300 7934
2975 7566
3000 7902
1100 7876
800 7369
3000 7788
1250 7521
1500 7844
1600 7499
SAL EMPNO
---------- ----------
950 7900
2850 7698
1250 7654
14 rows selected.
------把 empno 換成 ename
SQL> select distinct sal,ename from scott.emp order by deptno;
select distinct sal,ename from scott.emp order by deptno
*
ERROR at line 1:
ORA-01791: not a SELECTed expression
-----把,ename,empno 都加到select 中:
SQL> select distinct sal,ename,empno from scott.emp order by deptno;
SAL ENAME EMPNO
---------- -------------------- ----------
2450 CLARK 7782
5000 KING 7839
1300 MILLER 7934
2975 JONES 7566
3000 FORD 7902
1100 ADAMS 7876
800 SMITH 7369
3000 SCOTT 7788
1250 WARD 7521
1500 TURNER 7844
1600 ALLEN 7499
SAL ENAME EMPNO
---------- -------------------- ----------
950 JAMES 7900
2850 BLAKE 7698
1250 MARTIN 7654
14 rows selected.
SQL> select distinct sal,empno,sal from scott.emp order by deptno;
SAL EMPNO SAL
---------- ---------- ----------
2450 7782 2450
5000 7839 5000
1300 7934 1300
2975 7566 2975
3000 7902 3000
1100 7876 1100
800 7369 800
3000 7788 3000
1250 7521 1250
1500 7844 1500
1600 7499 1600
SAL EMPNO SAL
---------- ---------- ----------
950 7900 950
2850 7698 2850
1250 7654 1250
14 rows selected.
這裡為啥 empno 換成ename 後就無法執行了呢?
在做下以下測試:
---去掉empno 列上的主鍵
SQL> select distinct sal, empno from scott.t_emp order by deptno;
select distinct sal, empno from scott.t_emp order by deptno
*
ERROR at line 1:
ORA-01791: not a SELECTed expression
---新增empno 列上的主鍵
SQL> alter table t_emp add constraint pk_t_emp primary key(empno) ;
Table altered.
SQL> desc t_emp
Name Null? Type
----------------------------------------------------------------------------------- -------- --------------------------------------------------------
EMPNO NOT NULL NUMBER(4)
ENAME VARCHAR2(10)
JOB VARCHAR2(9)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)
DEPTNO NUMBER(2)
SQL> select distinct sal, empno from scott.t_emp order by deptno;
SAL EMPNO
---------- ----------
2450 7782
5000 7839
1300 7934
2975 7566
3000 7902
1100 7876
800 7369
3000 7788
1250 7521
1500 7844
1600 7499
950 7900
2850 7698
1250 7654
14 rows selected.
問題總結:
##########################################################
Restrictions on the ORDER BY Clause The following restrictions apply to the ORDER BY clause:
•If you have specified the DISTINCT operator in this statement, then this clause cannot refer to columns unless they appear in the select list.
•An order_by_clause can contain no more than 255 expressions.
•You cannot order by a LOB, LONG, or LONG RAW column, nested table, or varray.
•If you specify a group_by_clause in the same statement, then this order_by_clause is restricted to the following expressions:
◦Constants
◦Aggregate functions
◦Analytic functions
◦The functions USER, UID, and SYSDATE
◦Expressions identical to those in the group_by_clause
◦Expressions comprising the preceding expressions that evaluate to the same value for all rows in a group
##################################################################
ORA-01791: not a SELECTed expression after upgrade to 11.2.0.4 (Doc ID 1600974.1) To Bottom
________________________________________
In this Document
Symptoms
Changes
Cause
Solution
References
________________________________________
APPLIES TO:
Oracle Database - Enterprise Edition - Version 11.2.0.4 and later
Information in this document applies to any platform.
SYMPTOMS
a select DISTINCT query and the order by column does not reference a select list item after upgrade to 11.2.0.4
SQL> select distinct sal, empno from scott.emp order by deptno;
select distinct sal, empno from scott.emp order by deptno
*
ERROR at line 1:
ORA-01791: not a SELECTed expression
But it was working on previous release ..
SQL> select distinct sal, empno from scott.emp order by deptno;
SAL EMPNO
---------- ----------
2450 7782
5000 7839
CHANGES
upgrade to 11.2.0.4
CAUSE
The issue have been investigated in the following bug:
Bug:17655864 - ORA-01791: NOT A SELECTED EXPRESSION AFTER 11.2.0.4 PATCH
which is closed as not a bug. and this is expected behvior .
so the correct behavior is on 11.2.0.4 and not older versions.
This is due to
BUG 13768663 - SELECT WORKS IN 10.2 AND 11.2.0.3 FAILS 11.1.0.7 ORA-01791
Invalid query which should raise ORA-1791 is working fine without any error starting from 11.2.0.1.This is fixed in 11.2.0.4 and hence you may get the error ORA-1791 in 11.2.0.4.
SOLUTION
The expected behaviour for this statement is that it should report ORA-01791 That is, this is a select DISTINCT query and the order by column does not reference a select list item. This is a documented restriction of the order by clause.
http://docs.oracle.com/cd/E11882_01/server.112/e10592/statements_10002.htm#SQLRF20039
This behaviour is corrected through bugfix 13768663.
so please add the orderby column in the select statement
SQL> select distinct sal, empno, deptno from scott.emp order by deptno;
SAL EMPNO DEPTNO
---------- ---------- ----------
2450 7782 10
5000 7839 10
1300 7934 10
REFERENCES
BUG:17655864 - ORA-01791: NOT A SELECTED EXPRESSION AFTER 11.2.0.4 PATCH
NOTE:13768663.8 - Bug 13768663 - ORA-1791 not reported in 11.2 when expected
BUG:13768663 - SELECT WORKS IN 10.2 AND 11.2.0.3 FAILS 11.1.0.7 ORA-01791
相關推薦
ORA-01791: not a SELECTed expression 一個不是 bug 的 bug!
[[email protected] ~]$ !sql sqlplus / as sysdba SQL*Plus: Release 11.2.0.1.0 Production on Wed Aug 27 09:50:54 2014 Copyright (c) 19
ORA-01843: not a valid month 錯誤
insert into ......的場合發生ORA-01843: not a valid month 錯誤 原因是timestamp型別不一致。timestamp的日期格式為YYYY-MM-DD HH24:MI:SS.FF6 解決方法: alter session set
oracle報錯ORA-01843: not a valid month
alt sim valid session 成功 ora-01843 acl https lan 轉自:https://www.cnblogs.com/chonghaojie/p/9994625.html 客戶端:select * from sys.nls_session_
ORA-01843: not a valid month問題
這個問題是在oracle資料庫對時間格式的欄位做操作時出現無效的月份,這個問題是時間格式不對 我的解決方法是使用to_date函式顯示轉化為DATE型別的 sql.append(" and c.expected_effective_date = to_date(' "
ORA-01843: not a valid month我自己的解決方案
千尋(705122837) 16:39:29 兄弟們,今天 我新建一個表,在ORACLE環境下, create table abc(a int,b date); 建好後。插入資料: insert into abc values(99, '31-may-08')
輸入三角形的3條邊長(均為正整數),如果不能構成一個三角形,則輸出“not a triangle”;如果能夠構成一個直角三角形,則輸出“yes”;如果不能構成直角三角形,則輸出“no”。
題目描述 輸入三角形的3條邊長(均為正整數),如果不能構成一個三角形,則輸出“not a triangle”;如果能夠構成一個直角三角形,則輸出“yes”;如果不能構成直角三角形,則輸出“no”。 請將下面的程式填寫完整。 #include <stdio.h> int m
ORA-01791: 不是 SELECTed 表示式(distinct使用注意點)
not a Selected expression:不是一個查詢表示式; 原始報錯sql: select distinct report.fid as "reportId
ORA-23421: job number 225 is not a job in the job queue
conn uil bms delet ext roc erro declare dba_jobs 在對數據庫進行異機恢復之後,為了防止上面作業自動執行,擾亂正常業務系統,需要將測試庫上的作業和db_link進行刪除:但是使用sys用戶連接進去,刪除的時候報如下錯誤SQL
ORA-01665 control file is not a standby control file
描述 文件 oracle strong 錯誤處理 sta ora-01665 mount eat ORA-01665錯誤處理 問題描述: 在備庫啟動至mount狀態時,報如下錯誤: ORA-01665: control file is not a standby contr
你所不知道的 【ModuleNotFoundError: No module named ''; '' is not a package】
is not a package一、背景介紹 1. 工具目錄結構 為了便於統一管理一些小工具,在本地創建了一個mytools的目錄,子目錄的結構如下: 2.python搜索路徑在環境變量中,增加了PYTHONPATH的設置,value為‘e:\mytools\lib\python‘。二、問題
ubuntu下IDEA配置tomcat報錯Warning the selected directory is not a valid tomcat home
warn 技術 span 更改 文件目錄 tor 選擇 spa .com 產生這個問題的主要原因是文件夾權限問題。 可以修改文件夾權限或者更改tomcat文件目錄所有者。 這裏我直接變更tomcat文件夾所有者: sudo chown -R skh:skh tomcat-
不修改系統日期和時間格式,解決Delphi報錯提示 '****-**-**'is not a valid date and time
ali class ngs als ica 日期和時間 val 添加 ats 假如操作系統的日期格式不是yyyy-MM-dd格式,而是用strtodate(‘2014-10-01‘)) 來轉換的話,程序會提示爆粗 ‘****-**-**‘is not a valid dat
不互信情況下 A機器scp一個文件到B機器 無需密碼操作方法
Linux這個問題如果理解不深入的話很容易答錯,正確答案應該為:將A機器的id_rsa.pub(公鑰)輸出到B機器的authorized_keys中。操作步驟:(假設hadoop000為A hadoop001為B) 1.兩臺機器執行 [root@hadoop000 ~]# rm -rf ~/.ssh [roo
a標簽一個有用卻很多人不知道的屬性——rel="nofollow"
ike aik 多人 asp 爬蟲 IV 搜索 nbsp 抓取 最近想了解學些一下SEO,然後看了一些基礎的視頻,視頻裏提到了a標簽的rel="nofollow"屬性。說來慚愧,第一次看到這個屬性,都不知道這個屬性是幹嘛的 nofollow是什麽?
[IDEA]IntelliJ IDEA匯入JDK出現The selected directory is not a valid home for JDK問題的解決方法
昨天在實驗室的桌上型電腦上配置Java。之前一直在MAC上都是使用IntelliJ IDEA玩耍,這次也不能少了它。馬上上官網下載了一個Windows版的,用學生帳號註冊完之後,就可以直接使用了!但是在匯入JDK的時候遇到了問題 ,下圖是新增JDK的介面: 點選new按鈕後出現下圖:
Lodop“物件不支援SET__LICENSES屬性或方法”SET__LICENSES is not a function”
Lodop中的方法如果書寫錯誤,就會報錯:“物件不支援XXX屬性或方法”除錯JS會報錯”SET__LICENSES is not a function” LODOP.SET_LICENSES是加註冊語句,作為Lodop中的方法,如果寫錯,也會報類似的錯誤,“物件不支援SET__LICENSES屬性或方法”S
zookeeper is not a recognized option zookeeper引數不支援
– zookeeper is not a recognized option主要原因是 Kafka 版本過高,命令不存在。 解決方法 繼續使用新版本 ./bin/kafka-console-consumer.sh --bootstrap-server lo
ORA-23421: job number XXXX is not a job in the job queue
檢查一個數據庫的alert日誌時,檢視一些job報錯,由於是自己的測試庫,考慮把job停止掉。但是遇到如下錯誤: [email protected]>exec DBMS_JOB.broken(275,true); BEGIN DBMS_JOB.broken(275,true); END;
動態匯入模組,載入預訓練模型,nn.Sequential函式裡面必須是a Module subclass,不能是一個列表或者是其他的迭代器、生成器,雖然這裡麵包含了Module的子類
class RES(nn.Module): def __init__(self): super(RES, self).__init__() self.conv1=nn.Conv2d(3,64,kernel_size=7,stride=2,pa
tslib編譯使用方法(selected device is not a touchscreen I understand)
出現這個問題花了我兩個小時的時間才去解決掉,原因修改版本後忘了重新編譯LCD。 下面是我一直tslib 的詳細步驟: # tar -xzvf tslib-1.4.tar.gz # cd tslib # ./autogen.sh # mkdir tmp #