Oracle 检索数据
SELECT * | { [ DISTINCT ] column | expression [ alias ] , ... }
FROM table;
column后面加上空格,同一时候跟上别名(alias),或者 as 别名。到下一行的内容时,要用逗号隔开。
默认的别名是小写的。假设想要让它是大写的。使用 "别名"
假设别名有多个单词的时候,用双引號别名的方式 比方 “annual salary”
select employee_id id, first_name name from employees;
结果:
.....
193 Britney
194 Samuel
id NAME
------- --------------------
195 Vance
196 Alana
197 Kevin
107 rows selected
连接符:
select last_name||' `s eamil is '||email from employees;
类似于Java中的System.out.println(123+ “hello” + 123) ;//123hello123
默认情况下。查询会返回所有行,包含反复行。
SELECT last_name||' is a '||job_id
AS "Employee Details"
FROM employees;
列的别名:
SELECT last_name AS name,commission_pctcomm
FROM employees;
SELECT last_name "Name", salary*12 "AnnualSalary"
FROM employees;
The first example displays the names and the commission percentages of all the employees. Notice that theoptionalASkeyword has been used before the columnalias name. The
result of the query is the same whether the AS keyword is used or not. Also notice that the SQL statement has the column aliases, name and comm, in lowercase, whereas the result of the querydisplays the column headings inuppercase. As mentioned
in a previous slide, column headingsappear inuppercase by default.
默认的这样的没有引號的别名是大写的
Thesecond example displays the last names and annual salaries of all the employees.Because Annual Salarycontain a space, it has been enclosed in double quotation marks. Notice thatthe column heading in the output is exactly the same
as the column alias.
用双引號的这样的方式。能够将特殊的字符保留在引用的别名中。同一时候大写和小写和列的别名一致
在SELECT子句中使用keyword‘DISTINCT’删除反复行。
select distinct department_id from employees;
DEPARTMENT_ID
-------------
100
30
20
70
90
110
50
40
80
10
60
12 rows selected
定义空值
包括空值的数学表达式的值都为空值
SQL
语句与 SQL*Plus命令
Structural query language
SQL
SQL*Plus
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">
desc employees,desc是sql plus的keyword,全称是describe;
2. 包括空值的数学表达式的值都为空值
3. 别名使用双引號!
4. oracle 中连接字符串使用 "||", 而不是 java 中的 "+"
5. 日期和字符仅仅能在单引號中出现. 输出 last_name`s email is email
select last_name || ' `s email is ' || email EMAIL
from employees
6. distinct keyword, 下面语法错误
select last_name, distinct department_id
from employees
习题:
SQL*PLUS命令能够控制数据库吗?否!SQL*PLUS仅仅是一个执行环境,控制数据库的是SQL语言。
Oracle 检索数据的更多相关文章
- Oracle 检索数据(查询数据、select语句)
用户对表或视图最常进行的操作就是检索数据,检索数据可以通过 select 语句来实现,该语句由多个子句组成,通过这些子句完成筛选.投影和连接等各种数据操作,最终得到想要的结果. 语法: select ...
- 吴裕雄 python oracle检索数据(2)
import cx_Oracle conn = cx_Oracle.connect("scott/admin@localhost:1521/orcl")cursor = conn. ...
- 吴裕雄 python oracle检索数据(1)
import cx_Oracle conn = cx_Oracle.connect("scott/admin@localhost:1521/ORCL")cursor = conn. ...
- 数据分页处理系列之一:Oracle表数据分页检索SQL
关于Oracle数据分页检索SQL语法,网络上比比皆是,花样繁多,本篇也是笔者本人在网络上搜寻的比较有代表性的语法,绝非本人原创,贴在这里,纯粹是为了让"数据分页专题系列"看起 ...
- 学习笔记:oracle学习三:SQL语言基础之检索数据:简单查询、筛选查询
目录 1. 检索数据 1.1 简单查询 1.1.1 检索所有列 1.1.2 检索指定的列 1.1.3 查询日期列 1.1.4 带有表达式的select语句 1.1.5 为列指定别名 1.1.6 显示不 ...
- InnoDB这种行锁实现特点意味者:只有通过索引条件检索数据,InnoDB才会使用行级锁,否则,InnoDB将使用表锁!
InnoDB行锁是通过索引上的索引项来实现的,这一点MySQL与Oracle不同,后者是通过在数据中对相应数据行加锁来实现的. InnoDB这种行锁实现特点意味者:只有通过索引条件检索数据,InnoD ...
- sqoop工具从oracle导入数据2
sqoop工具从oracle导入数据 sqoop工具是hadoop下连接关系型数据库和Hadoop的桥梁,支持关系型数据库和hive.hdfs,hbase之间数据的相互导入,可以使用全表导入和增量导入 ...
- 使用SELECT语句检索数据
使用SELECT语句检索数据select指令适用于SQL数据库SELECT 语句用于从数据库中选取数据.(指令不分大小写,选择的值除名字和一些有特殊意义的字符可不分大小写,from结束时一定要加;) ...
- mysql-3 检索数据(1)
SELECT 语句 SELECT检索表数据,必须至少给出两条信息--------想选择什么,以及从什么地方选择. 检索一个列 SELECT prod_name FROM products; 上述语句利 ...
随机推荐
- 【BZOJ 4169】 4169: Lmc的游戏 (树形DP)
4169: Lmc的游戏 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 44 Solved: 25 Description RHL有一天看到lmc在 ...
- 在centos6.0上通过nginx远程执行shell
nginx本身不支持直接调用shell脚本,我们可以通过安装fastcgi程序,让nginx把调用shell的http请求交给fastcgi程序去处理,然后nginx 再将结果返回给用户方式间接调用s ...
- linux基础命令学习(十二)yum命令
主要功能是更方便的添加/删除/更新RPM包. 它能自动解决包的倚赖性问题. 它能便于管理大量系统的更新问题 yum list|more 列出所有包文件,可搭配grep查 ...
- extjs用iframe的问题
项目中用extjs做前提系统的界面是左边用树做目录 右边用tabpanel做内容展示点击树节点的时候 在tabpanel添加新的tab JScript code var newTab = center ...
- object-c语言的nonatomic,assign,copy,retain的区别
nonatomic: 非原子性访问,不加同步,多线程并发访问会提高性能.如果不加此属性,则默认是两个访问方法都为原子型事务访问. (atomic是Objc使用的一 ...
- POJ 1222 POJ 1830 POJ 1681 POJ 1753 POJ 3185 高斯消元求解一类开关问题
http://poj.org/problem?id=1222 http://poj.org/problem?id=1830 http://poj.org/problem?id=1681 http:// ...
- Altium Protel PCB Layer
The layers themselves are grouped by their functional types: Signal Layers – Top Layer, Bottom Layer ...
- 关于orcad元件库
ORCAD CAPTURE 零件库解析 ORCAD CAPTURE 零件库解析 1' AMPLIFIER.OLB 共182个零件,存放模拟放大器IC,如CA3280,TL027C,EL4093等. 2 ...
- jquery.lazyload.js实现图片懒载入
个人理解:将须要延迟载入的图片的src属性所有设置为一张同样尽可能小(目的是尽可能的少占宽带,节省流量,因为缓存机制,当浏览器载入了一张图片之后,同样的图片就会在缓存中拿.不会又一次到server上拿 ...
- Entity Framework 6 vs NHibernate 4
This article is dedicated to discussing the latest releases of the NHibernate and Entity Framework. ...