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进程的堆栈空间_代码段(指令,只读)、数据段(静态变量,全局变量)、堆栈段(局部变量)、栈【转】

    转自:http://blog.csdn.net/gongweijiao/article/details/8207333 原文参见:http://blog.163.com/xychenbaihu@yea ...

  2. eclipse 利用已有c++代码建工程,并编译执行

    如果你想建一个带Makefile的c++ 工程 1. 新建一个C++空工程,工程类型是makefile project,选择Linux GCC: 2. 将源码连同makefile文件一同作为一个文件系 ...

  3. SQLServer学习笔记<>相关子查询及复杂查询

    二.查询缺少值的查询 在这里我们加入要查询2008年每一天的订单有多少?首先我们可以查询下订单表的订单日期在2008年的所有订单信息. 1 select distinct orderdate,coun ...

  4. php中的curl】php中curl的详细解说

    本文我来给大家详细介绍下cURL的简单的使用方法,下文我将会给大家详细介绍cURL的高级应用, cURL可以使用URL的语法模拟浏览器来传输数据, FTP, FTPS, HTTP, HTTPS, GO ...

  5. 对Discuz的简单认识

    Discuz是php的一个开源论坛系统,是由康盛创想公司2004开发,从Discuz! 1.0到 现在的Discuz X3,无论从功能上还是从用户体验上,都达到了一个质的飞越.主要包括论坛.门户.群组 ...

  6. Serializable接口使用纪实

    这两天依领导要求使用sonar工具测试了一下项目代码,其中有一个问题是 而这个类的结构大概是这样的: public class Demo<T> implements Serializabl ...

  7. html里文本保留换行格式

    用<pre></pre>把文本包起来

  8. FTP协议标准命令

    FTP:文件传输协议(File Transfer Protocol) 文件传输协议(FTP)使得主机间可以共享文件.FTP 使用 TCP 生成一个虚拟连接用于控制信息,然后再生成一个单独的 TCP 连 ...

  9. (1)redis下载编译

    一.redis下载编译 这里没什么好说的 用的版本是redis-2.8.17 1)redis-server是可执行程序 2)mian函数在redis.c里面 3)如果要修改调试 这届在src目录下   ...

  10. linux Centos 6.5 FTP服务原理及vsfptd的安装、配置(转)

    本篇随笔将讲解FTP服务的原理以及vsfptd这个最常用的FTP服务程序的安装与配置... 一.FTP服务原理 FTP(File Transfer Protocol)是一个非常古老并且应用十分广泛的文 ...