Student表有3个字段:id,name,age

看这两个SQL语句

(1)select name from student order by id;

(2)select distinct(name) from student order by id;

执行结果你可能会说:

第1句返回以id排序的所有name字段

第2句返回以id排序的所有不重复的name字段.

但是执行结果不是这样的,第2句会报ORA-01791: not a SELECTed expression

原因:

一般来说,order by 的排序字段是可以不出现在select查询字段列表中的,但当查询中使用了DISTINCT或者GROUP BY子句时,order by中的排序字段就必须出现在select列表中,否则就会报上述错误.

第2句应改成  select distinct(name),id from student order by id

或者         select distinct(name) from student order by name

ORA-01791: not a SELECTed expression的更多相关文章

  1. ORA-01791: not a SELECTed expression 一种是不 bug 的 bug!

    [ora11@lixora ~]$ !sql sqlplus / as sysdba SQL*Plus: Release 11.2.0.1.0 Production on Wed Aug 27 09: ...

  2. [20170728]oracle保留字.txt

    [20170728]oracle保留字.txt --//oracle有许多保留字,我印象最深的就是使用rman备份表空间test,test就是rman里面的保留字.--//还有rman也是rman里面 ...

  3. Visual Studio 2010 Shortcut

    General Shortcut Description Ctrl-X or Shift-Delete Cuts the currently selected item to the clipboar ...

  4. 零元学Expression Blend 4 - Chapter 27 PathlistBox被Selected时的蓝底蓝框问题

    原文:零元学Expression Blend 4 - Chapter 27 PathlistBox被Selected时的蓝底蓝框问题 最近收到网友Cloud的来信,询问我有关放进PathlistBox ...

  5. ORA 各种oraclesql错误

    ORA-00001: 违反唯一约束条件 (.) ORA-00017: 请求会话以设置跟踪事件 ORA-00018: 超出最大会话数 ORA-00019: 超出最大会话许可数 ORA-00020: 超出 ...

  6. (转载)SQL Reporting Services (Expression Examples)

    https://msdn.microsoft.com/en-us/library/ms157328(v=SQL.100).aspx Expressions are used frequently in ...

  7. Expression<Func<T,TResult>>和Func<T,TResult>

    1.Expression<Func<T,TResult>>是表达式 //使用LambdaExpression构建表达式树 Expression<Func<int, ...

  8. Microsoft Word Regular Expression

    Microsoft Word Regular Expression Word裏的正則表達式-不一樣的符號. 一.Normal Find and Replace 二.Search by using wi ...

  9. Oracle Ora 错误解决方案合集

    注:本文来源于 < Oracle学习笔记 --- Oracle ORA错误解决方案 > ORA-00001: 违反唯一约束条件 (.)错误说明:当在唯一索引所对应的列上键入重复值时,会触发 ...

随机推荐

  1. Confluence 6 导入 Active Directory 服务器证书 - UNIX

    为了让你的应用服务器能够信任你的目录服务器.你目录服务器上导出的证书需要导入到你应用服务器的 Java 运行环境中.JDK 存储了信任的证书,这个存储信任证书的文件称为一个 keystore.默认的 ...

  2. HDU1506(真心不错的DP)

    Largest Rectangle in a Histogram Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 ...

  3. spring PROPAGATION

    PROPAGATION_REQUIRED Support a current transaction; create a new one if none exists.  支持一个当前事务;如果不存在 ...

  4. EBS 中iSupplier模块中的MAPPING_ID

    在EBS的供应商模块中,有一个非常有意思的表 POS_SUPPLIER_MAPPINGS, 这个表中建立了supplier_reg_id,vendor_id,party_id之间的映射关系. 这个表中 ...

  5. spring中@Scope作用域的注解

    @Scope简单点说就是用来指定bean的作用域 官方解释是:scope用来声明IOC容器中的对象应该处的限定场景或者说该对象的存活空间,即在IOC容器在对象进入相应的scope之前,生成并装配这些对 ...

  6. File storage location distribution in firmware using binwalk

    tool function: Binwalk is a fast, easy to use tool for analyzing, reverse engineering, and extractin ...

  7. 【转载】oracle索引详解

    原文URL;http://www.oschina.net/question/30362_4057?fromerr=FiY27yLL 作者:crazyinsomnia 一. ROWID的概念 存储了ro ...

  8. Mysql/Mariadb 升级注意事项

    因需要使用到分区表,在业务不中断的情况下,可以新增分区,需要将原来的Mariadb10.1.25版本升级到Mariadb10.3.8. 1.升级步骤如下 1)新搭建Mariadb10.3.8版本的DB ...

  9. onedriver -1T容量,edu邮箱申请。

    https://www.cccs.edu/ Apply申请 以前申请过这个红石社区大学. 创建帐号 自己翻译一下填填吧. 注册完,进入My Account,下面会有 2,点进去,也是注册. 3,点进去 ...

  10. Java——IO类,字节流读数据

    body, table{font-family: 微软雅黑} table{border-collapse: collapse; border: solid gray; border-width: 2p ...