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; 上述语句利 ...
随机推荐
- listView 一个 item更新
韩梦飞沙 韩亚飞 313134555@qq.com yue31313 han_meng_fei_sha 1,更新对应的 view 的内容 2,通过viewHolder去 设置 值 3,调用一次 ...
- [BJOI2017]魔法咒语 --- AC自动机 + 矩阵优化
bzoj 4860 LOJ2180 洛谷P3175 [BJOI2017]魔法咒语 题目描述: Chandra 是一个魔法天才. 从一岁时接受火之教会洗礼之后,Chandra 就显示出对火元素无 ...
- 51nod1376 最长上升子序列的数量
机房的人问我树状数组怎么做这题...... 树状数组维护$len, num$表示$LIS$的长度和数量即可 复杂度$O(n \log n)$ 注:$O(n \log n)$二分+单调栈才是真神仙 具体 ...
- [CC-ANUCBC]Cards, bags and coins
[CC-ANUCBC]Cards, bags and coins 题目大意: 给你\(n(n\le10^5)\)个数,\(q(q\le30)\)次询问,问从中选取若干个数使得这些数之和为\(m(m\l ...
- <form> 标签 // HTML 表单 // from 表单转换成json 格式
<form> 标签 // HTML 表单 // from 表单转换成json 格式 form 表单,对开发人员来说是在熟悉不过的了,它是页面与web服务器交互时的重要信息来源 表 ...
- bzoj 1503: [NOI2004]郁闷的出纳员 -- 权值线段树
1503: [NOI2004]郁闷的出纳员 Time Limit: 5 Sec Memory Limit: 64 MB Description OIER公司是一家大型专业化软件公司,有着数以万计的员 ...
- system.ComponentModel.Win32Exception (0x80004005): 目录名无效。 解决方法
有时候我们需要在程序中调用 cmd.exe 执行一些命令 比如 我们会在程序写到 /// <summary> /// 执行Cmd命令 /// </summary> /// & ...
- 在iOS 7中使用storyboard(part 1)
原文:Storyboards Tutorial in iOS 7: Part 1 感谢翻译小组成员heartasice热心翻译.如果您有不错的原创或译文,欢迎提交给我们,更欢迎其他朋友加 ...
- java 中文与unicode互转
public class FontUtil { public static void main(String[] args) { System.out.println(chinaToUnicode(& ...
- python使用游标访问数据
游标是一种数据访问对象,可用于在表中迭代一组行或者向表中插入新行.游标有三种形式:搜索.插入或更新.游标通常用于读取现有几何和写入新几何. 每种类型的游标均由对应的 ArcPy 函数(SearchCu ...