SQL> --别名
SQL> select ename 姓名, job as "工作" ,sal "薪水" from emp;

姓名                 工作                     薪水                                                                     
-------------------- ------------------ ----------                                                                     
SMITH                CLERK                     800                                                                     
ALLEN                SALESMAN                 1600                                                                     
WARD                 SALESMAN                 1250                                                                     
JONES                MANAGER                  2975                                                                     
MARTIN               SALESMAN                 1250                                                                     
BLAKE                MANAGER                  2850                                                                     
CLARK                MANAGER                  2450                                                                     
SCOTT                ANALYST                  3000                                                                     
KING                 PRESIDENT                5000                                                                     
TURNER               SALESMAN                 1500                                                                     
ADAMS                CLERK                    1100

姓名                 工作                     薪水                                                                     
-------------------- ------------------ ----------                                                                     
JAMES                CLERK                     950                                                                     
FORD                 ANALYST                  3000                                                                     
MILLER               CLERK                    1300

已选择14行。

SQL> --这三种别名有什么不同呢?
SQL> ed
SP2-0110: 无法创建保存文件 "afiedt.buf"
SQL> select ename 姓名, ename "姓名" from dual;
select ename 姓名, ename "姓名" from dual
                     *
第 1 行出现错误:
ORA-00904: "ENAME": 标识符无效

SQL> ed
SP2-0110: 无法创建保存文件 "afiedt.buf"
SQL> ed
SP2-0110: 无法创建保存文件 "afiedt.buf"
SQL> select * from emp;

EMPNO ENAME    JOB                       MGR HIREDATE              SAL       COMM    DEPTNO                       
---------- -------- ------------------ ---------- -------------- ---------- ---------- ---------                       
      7369 SMITH    CLERK                    7902 17-12月-80            800                   20                       
      7499 ALLEN    SALESMAN                 7698 20-2月 -81           1600        300        30                       
      7521 WARD     SALESMAN                 7698 22-2月 -81           1250        500        30                       
      7566 JONES    MANAGER                  7839 02-4月 -81           2975                   20                       
      7654 MARTIN   SALESMAN                 7698 28-9月 -81           1250       1400        30                       
      7698 BLAKE    MANAGER                  7839 01-5月 -81           2850                   30                       
      7782 CLARK    MANAGER                  7839 09-6月 -81           2450                   10                       
      7788 SCOTT    ANALYST                  7566 19-4月 -87           3000                   20                       
      7839 KING     PRESIDENT                     17-11月-81           5000                   10                       
      7844 TURNER   SALESMAN                 7698 08-9月 -81           1500          0        30                       
      7876 ADAMS    CLERK                    7788 23-5月 -87           1100                   20

EMPNO ENAME    JOB                       MGR HIREDATE              SAL       COMM    DEPTNO                       
---------- -------- ------------------ ---------- -------------- ---------- ---------- ---------                       
      7900 JAMES    CLERK                    7698 03-12月-81            950                   30                       
      7902 FORD     ANALYST                  7566 03-12月-81           3000                   20                       
      7934 MILLER   CLERK                    7782 23-1月 -82           1300                   10

已选择14行。

SQL> ed
SP2-0110: 无法创建保存文件 "afiedt.buf"
SQL> select ename 姓名, ename "姓名" from emp;

姓名                 姓名                                                                                              
-------------------- --------------------                                                                              
SMITH                SMITH                                                                                             
ALLEN                ALLEN                                                                                             
WARD                 WARD                                                                                              
JONES                JONES                                                                                             
MARTIN               MARTIN                                                                                            
BLAKE                BLAKE                                                                                             
CLARK                CLARK                                                                                             
SCOTT                SCOTT                                                                                             
KING                 KING                                                                                              
TURNER               TURNER                                                                                            
ADAMS                ADAMS

姓名                 姓名                                                                                              
-------------------- --------------------                                                                              
JAMES                JAMES                                                                                             
FORD                 FORD                                                                                              
MILLER               MILLER

已选择14行。

SQL> select ename 姓select/名, ename "姓名" from emp;
select ename 姓select/名, ename "姓名" from emp
                      *
第 1 行出现错误:
ORA-00923: 未找到要求的 FROM 关键字

SQL> select ename 姓名, ename "姓select/名" from emp;

姓名                 姓select/名                                                                                       
-------------------- --------------------                                                                              
SMITH                SMITH                                                                                             
ALLEN                ALLEN                                                                                             
WARD                 WARD                                                                                              
JONES                JONES                                                                                             
MARTIN               MARTIN                                                                                            
BLAKE                BLAKE                                                                                             
CLARK                CLARK                                                                                             
SCOTT                SCOTT                                                                                             
KING                 KING                                                                                              
TURNER               TURNER                                                                                            
ADAMS                ADAMS

姓名                 姓select/名                                                                                       
-------------------- --------------------                                                                              
JAMES                JAMES                                                                                             
FORD                 FORD                                                                                              
MILLER               MILLER

已选择14行。

SQL> select * from emp;

EMPNO ENAME    JOB                       MGR HIREDATE              SAL       COMM    DEPTNO                       
---------- -------- ------------------ ---------- -------------- ---------- ---------- ---------                       
      7369 SMITH    CLERK                    7902 17-12月-80            800                   20                       
      7499 ALLEN    SALESMAN                 7698 20-2月 -81           1600        300        30                       
      7521 WARD     SALESMAN                 7698 22-2月 -81           1250        500        30                       
      7566 JONES    MANAGER                  7839 02-4月 -81           2975                   20                       
      7654 MARTIN   SALESMAN                 7698 28-9月 -81           1250       1400        30                       
      7698 BLAKE    MANAGER                  7839 01-5月 -81           2850                   30                       
      7782 CLARK    MANAGER                  7839 09-6月 -81           2450                   10                       
      7788 SCOTT    ANALYST                  7566 19-4月 -87           3000                   20                       
      7839 KING     PRESIDENT                     17-11月-81           5000                   10                       
      7844 TURNER   SALESMAN                 7698 08-9月 -81           1500          0        30                       
      7876 ADAMS    CLERK                    7788 23-5月 -87           1100                   20

EMPNO ENAME    JOB                       MGR HIREDATE              SAL       COMM    DEPTNO                       
---------- -------- ------------------ ---------- -------------- ---------- ---------- ---------                       
      7900 JAMES    CLERK                    7698 03-12月-81            950                   30                       
      7902 FORD     ANALYST                  7566 03-12月-81           3000                   20                       
      7934 MILLER   CLERK                    7782 23-1月 -82           1300                   10

已选择14行。

SQL> select job from emp;

JOB                                                                                                                    
------------------                                                                                                     
CLERK                                                                                                                  
SALESMAN                                                                                                               
SALESMAN                                                                                                               
MANAGER                                                                                                                
SALESMAN                                                                                                               
MANAGER                                                                                                                
MANAGER                                                                                                                
ANALYST                                                                                                                
PRESIDENT                                                                                                              
SALESMAN                                                                                                               
CLERK

JOB                                                                                                                    
------------------                                                                                                     
CLERK                                                                                                                  
ANALYST                                                                                                                
CLERK

已选择14行。

SQL> select distinct job from emp;

JOB                                                                                                                    
------------------                                                                                                     
CLERK                                                                                                                  
SALESMAN                                                                                                               
PRESIDENT                                                                                                              
MANAGER                                                                                                                
ANALYST

SQL> --去除结果集里面的重复数据
SQL> select distinct job,sal from emp;

JOB                       SAL                                                                                          
------------------ ----------                                                                                          
CLERK                    1300                                                                                          
SALESMAN                 1600                                                                                          
SALESMAN                 1250                                                                                          
CLERK                     950                                                                                          
CLERK                     800                                                                                          
MANAGER                  2450                                                                                          
PRESIDENT                5000                                                                                          
ANALYST                  3000                                                                                          
MANAGER                  2850                                                                                          
MANAGER                  2975                                                                                          
SALESMAN                 1500

JOB                       SAL                                                                                          
------------------ ----------                                                                                          
CLERK                    1100

已选择12行。

SQL> --如果distinct后面跟了多行,那么我们会将所有的行作为是否重复的标准。
SQL> --字符串的连接
SQL> select concat("hello","world") from emp;
select concat("hello","world") from emp
                      *
第 1 行出现错误:
ORA-00904: "world": 标识符无效

SQL> select concat('hello','world') from emp;

CONCAT('HELLO','WORL                                                                                                   
--------------------                                                                                                   
helloworld                                                                                                             
helloworld                                                                                                             
helloworld                                                                                                             
helloworld                                                                                                             
helloworld                                                                                                             
helloworld                                                                                                             
helloworld                                                                                                             
helloworld                                                                                                             
helloworld                                                                                                             
helloworld                                                                                                             
helloworld

CONCAT('HELLO','WORL                                                                                                   
--------------------                                                                                                   
helloworld                                                                                                             
helloworld                                                                                                             
helloworld

已选择14行。

SQL> --数据库的伪表
SQL> select concat('hello','world') from dual;

CONCAT('HELLO','WORL                                                                                                   
--------------------                                                                                                   
helloworld

SQL> select sysdate from dual;

SYSDATE                                                                                                                
--------------                                                                                                         
14-3月 -16

SQL> select sysdate from emp;

SYSDATE                                                                                                                
--------------                                                                                                         
14-3月 -16                                                                                                             
14-3月 -16                                                                                                             
14-3月 -16                                                                                                             
14-3月 -16                                                                                                             
14-3月 -16                                                                                                             
14-3月 -16                                                                                                             
14-3月 -16                                                                                                             
14-3月 -16                                                                                                             
14-3月 -16                                                                                                             
14-3月 -16                                                                                                             
14-3月 -16

SYSDATE                                                                                                                
--------------                                                                                                         
14-3月 -16                                                                                                             
14-3月 -16                                                                                                             
14-3月 -16

已选择14行。

SQL> select 'hello' || 'world' from dual;

'HELLO'||'WORLD'                                                                                                       
--------------------                                                                                                   
helloworld

SQL> select 'hello' || 'world' 世界你好 from dual;

世界你好                                                                                                               
--------------------                                                                                                   
helloworld

SQL> -- oracle中的单引号和双引号的区别
SQL> -- 单引号代表字符串,双引号代表别名
SQL> spool off;

oracle的基本查询~下的更多相关文章

  1. oracle之复杂查询(下):子查询

    复杂查询(下):子查询 8. 1 非关联子查询:返回的值可以被外部查询使用.子查询可以独立执行的(且仅执行一次). 8.1.1 单行单列子查询,子查询仅返回一个值,也称为标量子查询,采用单行比较运算符 ...

  2. oracle系统表查询

    oracle查询用户下的所有表 select * from all_tab_comments -- 查询所有用户的表,视图等select * from user_tab_comments -- 查询本 ...

  3. Oracle中分页查询语句

    Oracle分页查询语句使我们最常用的语句之一,下面就为您介绍的Oracle分页查询语句的用法,如果您对此方面感兴趣的话,不妨一看. Oracle分页查询语句基本上可以按照本文给出的格式来进行套用.O ...

  4. oracle数据库常用查询一

    oracle数据库常用查询一 sqlplus / as sysdba; 或sqlplus sys/密码 as sysdba;两者都是以sys登录.conn scott/tiger@orcl; conn ...

  5. Oracle的分页查询语句优化

    Oracle的分页查询语句基本上可以按照本文给出的格式来进行套用. (一)   分页查询格式: SELECT * FROM  ( SELECT A.*, ROWNUM RN  FROM (SELECT ...

  6. oracle 中对查询出来的数据进行切割、截取等操作

    oracle 中对查询出来的数据进行切割.截取等操作 最近遇到一个问题,需要把一个带有,的字符串拆分成多行.通过查询资料,这个操作需要使用以下2个关键知识: 1. REGEXP_SUBSTR函数 这个 ...

  7. Oracle 的分页查询 SQL 语句

    Oracle的分页查询语句基本上可以按照本文给出的格式来进行套用. 分页查询格式: SELECT * FROM (SELECT A.*, ROWNUM RN FROM (SELECT * FROM T ...

  8. Oracle锁表查询和解锁方法

    数据库操作语句的分类 DDL:数据库模式定义语言,关键字:create DML:数据操纵语言,关键字:Insert.delete.update DCL:数据库控制语言 ,关键字:grant.remov ...

  9. oracle锁表查询

    ORACLE EBS操作某一个FORM界面,或者后台数据库操作某一个表时发现一直出于"假死"状态,可能是该表被某一用户锁定,导致其他用户无法继续操作 复制代码代码如下: --锁表查 ...

随机推荐

  1. linux下的module_param()解释【转】

    转自:http://blog.csdn.net/wavemcu/article/details/7762133 版权声明:本文为博主原创文章,未经博主允许不得转载. ***************** ...

  2. html+css复习之第2篇 | javascript

    1. java 中定义数组和对象: 数组(Array)字面量 定义一个数组: [40, 100, 1, 5, 25, 10] 对象(Object)字面量 定义一个对象: {firstName:&quo ...

  3. 天大acm 题号1002 Maya Calendar

    Description 上周末,M.A. Ya教授对古老的玛雅有了一个重大发现.从一个古老的节绳(玛雅人用于记事的工具)中,教授发现玛雅人使用了一个一年有365天的叫做Haab的历法.这 个Haab历 ...

  4. Python 日期和时间

    Python 程序能用很多方式处理日期和时间,转换日期格式是一个常见的功能. Python 提供了一个 time 和 calendar 模块可以用于格式化日期和时间. 时间间隔是以秒为单位的浮点小数. ...

  5. Power Strings 分类: POJ 串 2015-07-31 19:05 8人阅读 评论(0) 收藏

    Time Limit:3000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Status Practice POJ ...

  6. 转载-python学习笔记之输入输出功能读取和写入数据

    读取.写入和 Python 在 “探索 Python” 系列以前的文章中,学习了基本的 Python 数据类型和一些容器数据类型,例如tuple.string 和 list.其他文章讨论了 Pytho ...

  7. lhgdialog在打开的窗口里点击按钮关闭当前窗口

    lhgdialog在打开的窗口里点击按钮关闭当前窗口 var api = frameElement.api, W = api.opener; api.close();

  8. 使用main方法调用http请求本地服务器的某个servlet报错问题

    java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:8081/test/myS ...

  9. SQL Server中常用的SQL语句

    1.概述 名词 笛卡尔积.主键.外键 数据完整性 实体完整性:主属性不能为空值,例如选课表中学号和课程号不能为空 参照完整性:表中的外键取值为空或参照表中的主键 用户定义完整性:取值范围或非空限制,例 ...

  10. apahce

    基本的操作方法:本文假设你的apahce安装目录为/usr/local/apache2,这些方法适合任何情况 apahce启动命令:推荐/usr/local/apache2/bin/apachectl ...