Oracle数据库:sql语言结构,数据查询语言DQL,select * from table;算术,别名,连接,去重等操作
Oracle数据库:sql语言结构,数据查询语言DQL,select * from table;算术,别名,连接,去重等操作
2022找工作是学历、能力和运气的超强结合体,遇到寒冬,大厂不招人,可能很多算法学生都得去找开发,测开
测开的话,你就得学数据库,sql,oracle,尤其sql要学,当然,像很多金融企业、安全机构啥的,他们必须要用oracle数据库
这oracle比sql安全,强大多了,所以你需要学习,最重要的,你要是考网络警察公务员,这玩意你不会就别去报名了,耽误时间!
oracle系列文章:
【1】Oracle数据库:啥是oracle数据库?你为啥要学oracle?
【2】Oracle数据库:oracle 11g安装教程,已安装好的oracle各个文件夹的作用,oracle用户权限怎么样
【3】Oracle数据库:oracle启动,oracle客户端工具plsql安装教程和使用方法
【4】Oracle数据库:创建表空间,创建新用户,给用户分配对象、角色和系统权限,登录新用户建表
【5】Oracle数据库:链接配置,包括sqlnet.ora里面的transnames.ora配置数据库标识符SID,listener暂时简单了解
【6】Oracle数据库:net configureation assistant工具配置监听listener,配置本地网络访问服务器上的数据库
【7】Oracle数据库:oracle字符类型、数字类型、创建表表名的命名规则
【8】Oracle数据库:约束条件:主键约束、唯一约束、检查约束、非空约束、外键约束、默认值填写
【9】Oracle数据库:表的关系:一对多,一对一,多对多,一一继承和修改的关系,表不是重点,重点是数据和约束关系
文章目录
- Oracle数据库:sql语言结构,数据查询语言DQL,select * from table;算术,别名,连接,去重等操作
- @[TOC](文章目录)
- oracle:SQL语言
- sql语言结构
- 数据查询语言DQL
- 编写基本的select语句
- select的算术表达式
- null既不是0,也不是空格,因为0是数字,而空格是字符,null是虚无
- 列名的别名修改
- 连字运算符,||,连接字符
- 文字字符串
- 去除重复行DISTINCT
- selcet语句小练习
- 数据操作语言DML
- 事物处理语言TCL
- 数据控制语言DCL
- 数据定义语言:DDL
- 总结
oracle:SQL语言
查询和程序设计语言
操作数据库
只能依赖于sql语言
咱们plsql客户端目的也是帮助生成sql语言
可视化给我们看
不需要学全部,只需要代表性的
我们用的oracle11g支持sql99版【向下兼容】
很多厂商不见得都支持ISO定制的标准
一般oracle会有自己的扩展,无法使用到mysql中
sql语言结构
数据查询语言DQL
咱们要讲这些语言
你不就得建表,查询吗?
但是自己建表很麻烦,oracle数据库有一个默认的用户HR,它里面有很多示例,所以我们可以借此登录成为HR用户
然后查它已经有了的数据,练习上面这个数据查询语言DQL
dba身份登录sys
把user下面的hr用户的密码设置一下,然后解锁
你再登录了HR
然后就可以发现有7个样例表格
国家、部门、员工,工作、历史工作、地址、区域
我们得知道表结构,应该是有一个命令的
右击edit,看columns
这就是我们经常玩的方法
还有就是用cmdWindows
用desc命令【description的简写,看描述】
desc 表名;
SQL> desc countries;
Name Type Nullable Default Comments
------------ ------------ -------- ------- ------------------------------------------------------------------------------------
COUNTRY_ID CHAR(2) Primary key of countries table.
COUNTRY_NAME VARCHAR2(40) Y Country name
REGION_ID NUMBER Y Region ID for the country. Foreign key to region_id column in the departments table.
可以看见表的列明,数据类型,他们的comments注释
region_id是departments的外键
编写基本的select语句
*是所有的列
想要部分列,就给定特定的列名
DISTINCT是去除重复的过多的数据,剔除,保留补不重复的数据
sql语句至少要有select 和from,一个选择列,一个选择表
你写命令可以用小写,sql会自动转大写的
sql写表格名字,列名也是不敏感的
数据里面的大小写是区分的
SQL> select * from departments;DEPARTMENT_ID DEPARTMENT_NAME MANAGER_ID LOCATION_ID
------------- ------------------------------ ---------- -----------10 Administration 200 170020 Marketing 201 180030 Purchasing 114 170040 Human Resources 203 240050 Shipping 121 150060 IT 103 140070 Public Relations 204 270080 Sales 145 250090 Executive 100 1700100 Finance 108 1700110 Accounting 205 1700120 Treasury 1700130 Corporate Tax 1700140 Control And Credit 1700150 Shareholder Services 1700160 Benefits 1700170 Manufacturing 1700180 Construction 1700190 Contracting 1700200 Operations 1700DEPARTMENT_ID DEPARTMENT_NAME MANAGER_ID LOCATION_ID
------------- ------------------------------ ---------- -----------210 IT Support 1700220 NOC 1700230 IT Helpdesk 1700240 Government Sales 1700250 Retail Sales 1700260 Recruiting 1700270 Payroll 170027 rows selectedSQL>
你会发现这个表格,数字靠右侧贴近
文字靠左贴近显示
可以学会美化sql语句
关键字不可分开
反正很直白
select 列,from 表
【这是考网警最基础的骚操作,你要会的】
如果你只想看DEPARTMENT_NAME,则这么搞
SQL> select department_name from departments;DEPARTMENT_NAME
------------------------------
Administration
Marketing
Purchasing
Human Resources
Shipping
IT
Public Relations
Sales
Executive
Finance
Accounting
Treasury
Corporate Tax
Control And Credit
Shareholder Services
Benefits
Manufacturing
Construction
Contracting
OperationsDEPARTMENT_NAME
------------------------------
IT Support
NOC
IT Helpdesk
Government Sales
Retail Sales
Recruiting
Payroll27 rows selected
如何,就只有部门名字了吧,美滋滋
select的算术表达式
这些知识点,跟常规的程序语言一模一样
所以你程序界,一通百通
SQL> desc employees;
Name Type Nullable Default Comments
-------------- ------------ -------- ------- -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
EMPLOYEE_ID NUMBER(6) Primary key of employees table.
FIRST_NAME VARCHAR2(20) Y First name of the employee. A not null column.
LAST_NAME VARCHAR2(25) Last name of the employee. A not null column.
EMAIL VARCHAR2(25) Email id of the employee
PHONE_NUMBER VARCHAR2(20) Y Phone number of the employee; includes country code and area code
HIRE_DATE DATE Date when the employee started on this job. A not null column.
JOB_ID VARCHAR2(10) Current job of the employee; foreign key to job_id column of the
jobs table. A not null column.
SALARY NUMBER(8,2) Y Monthly salary of the employee. Must be greater
than zero (enforced by constraint emp_salary_min)
COMMISSION_PCT NUMBER(2,2) Y Commission percentage of the employee; Only employees in sales
department elgible for commission percentage
MANAGER_ID NUMBER(6) Y Manager id of the employee; has same domain as manager_id in
departments table. Foreign key to employee_id column of employees table.
(useful for reflexive joins and CONNECT BY query)
DEPARTMENT_ID NUMBER(4) Y Department id where employee works; foreign key to department_id
column of the departments table
里面有薪水salary
你要全年的薪水的话,需要12*月薪呗
然后加100好说,整体只增加100元,仅此而已
SQL> select employee_id,first_name,last_name,salary,salary*12+100 from employees;EMPLOYEE_ID FIRST_NAME LAST_NAME SALARY SALARY*12+100
----------- -------------------- ------------------------- ---------- -------------100 Steven King 24000.00 288100101 Neena Kochhar 17000.00 204100102 Lex De Haan 17000.00 204100103 Alexander Hunold 9000.00 108100104 Bruce Ernst 6000.00 72100105 David Austin 4800.00 57700106 Valli Pataballa 4800.00 57700107 Diana Lorentz 4200.00 50500108 Nancy Greenberg 12008.00 144196109 Daniel Faviet 9000.00 108100110 John Chen 8200.00 98500111 Ismael Sciarra 7700.00 92500112 Jose Manuel Urman 7800.00 93700113 Luis Popp 6900.00 82900114 Den Raphaely 11000.00 132100115 Alexander Khoo 3100.00 37300116 Shelli Baida 2900.00 34900117 Sigal Tobias 2800.00 33700118 Guy Himuro 2600.00 31300119 Karen Colmenares 2500.00 30100EMPLOYEE_ID FIRST_NAME LAST_NAME SALARY SALARY*12+100
----------- -------------------- ------------------------- ---------- -------------120 Matthew Weiss 8000.00 96100121 Adam Fripp 8200.00 98500122 Payam Kaufling 7900.00 94900123 Shanta Vollman 6500.00 78100124 Kevin Mourgos 5800.00 69700125 Julia Nayer 3200.00 38500126 Irene Mikkilineni 2700.00 32500127 James Landry 2400.00 28900128 Steven Markle 2200.00 26500129 Laura Bissot 3300.00 39700130 Mozhe Atkinson 2800.00 33700131 James Marlow 2500.00 30100132 TJ Olson 2100.00 25300133 Jason Mallin 3300.00 39700134 Michael Rogers 2900.00 34900135 Ki Gee 2400.00 28900136 Hazel Philtanker 2200.00 26500137 Renske Ladwig 3600.00 43300138 Stephen Stiles 3200.00 38500139 John Seo 2700.00 32500140 Joshua Patel 2500.00 30100EMPLOYEE_ID FIRST_NAME LAST_NAME SALARY SALARY*12+100
----------- -------------------- ------------------------- ---------- -------------141 Trenna Rajs 3500.00 42100142 Curtis Davies 3100.00 37300143 Randall Matos 2600.00 31300144 Peter Vargas 2500.00 30100145 John Russell 14000.00 168100146 Karen Partners 13500.00 162100147 Alberto Errazuriz 12000.00 144100148 Gerald Cambrault 11000.00 132100149 Eleni Zlotkey 10500.00 126100150 Peter Tucker 10000.00 120100151 David Bernstein 9500.00 114100152 Peter Hall 9000.00 108100153 Christopher Olsen 8000.00 96100154 Nanette Cambrault 7500.00 90100155 Oliver Tuvault 7000.00 84100156 Janette King 10000.00 120100157 Patrick Sully 9500.00 114100158 Allan McEwen 9000.00 108100159 Lindsey Smith 8000.00 96100160 Louise Doran 7500.00 90100161 Sarath Sewall 7000.00 84100EMPLOYEE_ID FIRST_NAME LAST_NAME SALARY SALARY*12+100
----------- -------------------- ------------------------- ---------- -------------162 Clara Vishney 10500.00 126100163 Danielle Greene 9500.00 114100164 Mattea Marvins 7200.00 86500165 David Lee 6800.00 81700166 Sundar Ande 6400.00 76900167 Amit Banda 6200.00 74500168 Lisa Ozer 11500.00 138100169 Harrison Bloom 10000.00 120100170 Tayler Fox 9600.00 115300171 William Smith 7400.00 88900172 Elizabeth Bates 7300.00 87700173 Sundita Kumar 6100.00 73300174 Ellen Abel 11000.00 132100175 Alyssa Hutton 8800.00 105700176 Jonathon Taylor 8600.00 103300177 Jack Livingston 8400.00 100900178 Kimberely Grant 7000.00 84100179 Charles Johnson 6200.00 74500180 Winston Taylor 3200.00 38500181 Jean Fleaur 3100.00 37300182 Martha Sullivan 2500.00 30100EMPLOYEE_ID FIRST_NAME LAST_NAME SALARY SALARY*12+100
----------- -------------------- ------------------------- ---------- -------------183 Girard Geoni 2800.00 33700184 Nandita Sarchand 4200.00 50500185 Alexis Bull 4100.00 49300186 Julia Dellinger 3400.00 40900187 Anthony Cabrio 3000.00 36100188 Kelly Chung 3800.00 45700189 Jennifer Dilly 3600.00 43300190 Timothy Gates 2900.00 34900191 Randall Perkins 2500.00 30100192 Sarah Bell 4000.00 48100193 Britney Everett 3900.00 46900194 Samuel McCain 3200.00 38500195 Vance Jones 2800.00 33700196 Alana Walsh 3100.00 37300197 Kevin Feeney 3000.00 36100198 Donald OConnell 2600.00 31300199 Douglas Grant 2600.00 31300200 Jennifer Whalen 4400.00 52900201 Michael Hartstein 13000.00 156100202 Pat Fay 6000.00 72100203 Susan Mavris 6500.00 78100EMPLOYEE_ID FIRST_NAME LAST_NAME SALARY SALARY*12+100
----------- -------------------- ------------------------- ---------- -------------204 Hermann Baer 10000.00 120100205 Shelley Higgins 12008.00 144196206 William Gietz 8300.00 99700107 rows selected
我们选择了employee_id,first_name,last_name,salary,salary*12+100列
你会发现,展示了这些列
而且薪水那有10000的
12个月就是120000
再加100,就是120100
那如果是月薪+100,再计算全年薪水,应该很多,增加了1200元
这就很好说了,先加括号,然后再乘12
SQL> select employee_id,first_name,last_name,salary,(salary+100)*12 from employees;EMPLOYEE_ID FIRST_NAME LAST_NAME SALARY (SALARY+100)*12
----------- -------------------- ------------------------- ---------- ---------------100 Steven King 24000.00 289200101 Neena Kochhar 17000.00 205200102 Lex De Haan 17000.00 205200103 Alexander Hunold 9000.00 109200104 Bruce Ernst 6000.00 73200105 David Austin 4800.00 58800106 Valli Pataballa 4800.00 58800107 Diana Lorentz 4200.00 51600108 Nancy Greenberg 12008.00 145296109 Daniel Faviet 9000.00 109200110 John Chen 8200.00 99600111 Ismael Sciarra 7700.00 93600112 Jose Manuel Urman 7800.00 94800113 Luis Popp 6900.00 84000114 Den Raphaely 11000.00 133200115 Alexander Khoo 3100.00 38400116 Shelli Baida 2900.00 36000117 Sigal Tobias 2800.00 34800118 Guy Himuro 2600.00 32400119 Karen Colmenares 2500.00 31200EMPLOYEE_ID FIRST_NAME LAST_NAME SALARY (SALARY+100)*12
----------- -------------------- ------------------------- ---------- ---------------120 Matthew Weiss 8000.00 97200121 Adam Fripp 8200.00 99600122 Payam Kaufling 7900.00 96000123 Shanta Vollman 6500.00 79200124 Kevin Mourgos 5800.00 70800125 Julia Nayer 3200.00 39600126 Irene Mikkilineni 2700.00 33600127 James Landry 2400.00 30000128 Steven Markle 2200.00 27600129 Laura Bissot 3300.00 40800130 Mozhe Atkinson 2800.00 34800131 James Marlow 2500.00 31200132 TJ Olson 2100.00 26400133 Jason Mallin 3300.00 40800134 Michael Rogers 2900.00 36000135 Ki Gee 2400.00 30000136 Hazel Philtanker 2200.00 27600137 Renske Ladwig 3600.00 44400138 Stephen Stiles 3200.00 39600139 John Seo 2700.00 33600140 Joshua Patel 2500.00 31200EMPLOYEE_ID FIRST_NAME LAST_NAME SALARY (SALARY+100)*12
----------- -------------------- ------------------------- ---------- ---------------141 Trenna Rajs 3500.00 43200142 Curtis Davies 3100.00 38400143 Randall Matos 2600.00 32400144 Peter Vargas 2500.00 31200145 John Russell 14000.00 169200146 Karen Partners 13500.00 163200147 Alberto Errazuriz 12000.00 145200148 Gerald Cambrault 11000.00 133200149 Eleni Zlotkey 10500.00 127200150 Peter Tucker 10000.00 121200151 David Bernstein 9500.00 115200152 Peter Hall 9000.00 109200153 Christopher Olsen 8000.00 97200154 Nanette Cambrault 7500.00 91200155 Oliver Tuvault 7000.00 85200156 Janette King 10000.00 121200157 Patrick Sully 9500.00 115200158 Allan McEwen 9000.00 109200159 Lindsey Smith 8000.00 97200160 Louise Doran 7500.00 91200161 Sarath Sewall 7000.00 85200EMPLOYEE_ID FIRST_NAME LAST_NAME SALARY (SALARY+100)*12
----------- -------------------- ------------------------- ---------- ---------------162 Clara Vishney 10500.00 127200163 Danielle Greene 9500.00 115200164 Mattea Marvins 7200.00 87600165 David Lee 6800.00 82800166 Sundar Ande 6400.00 78000167 Amit Banda 6200.00 75600168 Lisa Ozer 11500.00 139200169 Harrison Bloom 10000.00 121200170 Tayler Fox 9600.00 116400171 William Smith 7400.00 90000172 Elizabeth Bates 7300.00 88800173 Sundita Kumar 6100.00 74400174 Ellen Abel 11000.00 133200175 Alyssa Hutton 8800.00 106800176 Jonathon Taylor 8600.00 104400177 Jack Livingston 8400.00 102000178 Kimberely Grant 7000.00 85200179 Charles Johnson 6200.00 75600180 Winston Taylor 3200.00 39600181 Jean Fleaur 3100.00 38400182 Martha Sullivan 2500.00 31200EMPLOYEE_ID FIRST_NAME LAST_NAME SALARY (SALARY+100)*12
----------- -------------------- ------------------------- ---------- ---------------183 Girard Geoni 2800.00 34800184 Nandita Sarchand 4200.00 51600185 Alexis Bull 4100.00 50400186 Julia Dellinger 3400.00 42000187 Anthony Cabrio 3000.00 37200188 Kelly Chung 3800.00 46800189 Jennifer Dilly 3600.00 44400190 Timothy Gates 2900.00 36000191 Randall Perkins 2500.00 31200192 Sarah Bell 4000.00 49200193 Britney Everett 3900.00 48000194 Samuel McCain 3200.00 39600195 Vance Jones 2800.00 34800196 Alana Walsh 3100.00 38400197 Kevin Feeney 3000.00 37200198 Donald OConnell 2600.00 32400199 Douglas Grant 2600.00 32400200 Jennifer Whalen 4400.00 54000201 Michael Hartstein 13000.00 157200202 Pat Fay 6000.00 73200203 Susan Mavris 6500.00 79200EMPLOYEE_ID FIRST_NAME LAST_NAME SALARY (SALARY+100)*12
----------- -------------------- ------------------------- ---------- ---------------204 Hermann Baer 10000.00 121200205 Shelley Higgins 12008.00 145296206 William Gietz 8300.00 100800107 rows selected
对于工资10000的
加100
10100
那乘12个月
就是121200
简单吧
算术运算就OK了
null既不是0,也不是空格,因为0是数字,而空格是字符,null是虚无
SQL> desc employees;
Name Type Nullable Default Comments
-------------- ------------ -------- ------- -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
EMPLOYEE_ID NUMBER(6) Primary key of employees table.
FIRST_NAME VARCHAR2(20) Y First name of the employee. A not null column.
LAST_NAME VARCHAR2(25) Last name of the employee. A not null column.
EMAIL VARCHAR2(25) Email id of the employee
PHONE_NUMBER VARCHAR2(20) Y Phone number of the employee; includes country code and area code
HIRE_DATE DATE Date when the employee started on this job. A not null column.
JOB_ID VARCHAR2(10) Current job of the employee; foreign key to job_id column of the
jobs table. A not null column.
SALARY NUMBER(8,2) Y Monthly salary of the employee. Must be greater
than zero (enforced by constraint emp_salary_min)
COMMISSION_PCT NUMBER(2,2) Y Commission percentage of the employee; Only employees in sales
department elgible for commission percentage
MANAGER_ID NUMBER(6) Y Manager id of the employee; has same domain as manager_id in
departments table. Foreign key to employee_id column of employees table.
(useful for reflexive joins and CONNECT BY query)
DEPARTMENT_ID NUMBER(4) Y Department id where employee works; foreign key to department_id
column of the departments table
你看那个COMMISSION_PCT佣金
不见得人人都有佣金的
你可以查一波
SQL> select last_name,commission_pct,12*salary + commission_pct from employees;LAST_NAME COMMISSION_PCT 12*SALARY+COMMISSION_PCT
------------------------- -------------- ------------------------
King
Kochhar
De Haan
Hunold
Ernst
Austin
Pataballa
Lorentz
Greenberg
Faviet
Chen
Sciarra
Urman
Popp
Raphaely
Khoo
Baida
Tobias
Himuro
Colmenares LAST_NAME COMMISSION_PCT 12*SALARY+COMMISSION_PCT
------------------------- -------------- ------------------------
Weiss
Fripp
Kaufling
Vollman
Mourgos
Nayer
Mikkilineni
Landry
Markle
Bissot
Atkinson
Marlow
Olson
Mallin
Rogers
Gee
Philtanker
Ladwig
Stiles
Seo
Patel LAST_NAME COMMISSION_PCT 12*SALARY+COMMISSION_PCT
------------------------- -------------- ------------------------
Rajs
Davies
Matos
Vargas
Russell 0.40 168000.4
Partners 0.30 162000.3
Errazuriz 0.30 144000.3
Cambrault 0.30 132000.3
Zlotkey 0.20 126000.2
Tucker 0.30 120000.3
Bernstein 0.25 114000.25
Hall 0.25 108000.25
Olsen 0.20 96000.2
Cambrault 0.20 90000.2
Tuvault 0.15 84000.15
King 0.35 120000.35
Sully 0.35 114000.35
McEwen 0.35 108000.35
Smith 0.30 96000.3
Doran 0.30 90000.3
Sewall 0.25 84000.25LAST_NAME COMMISSION_PCT 12*SALARY+COMMISSION_PCT
------------------------- -------------- ------------------------
Vishney 0.25 126000.25
Greene 0.15 114000.15
Marvins 0.10 86400.1
Lee 0.10 81600.1
Ande 0.10 76800.1
Banda 0.10 74400.1
Ozer 0.25 138000.25
Bloom 0.20 120000.2
Fox 0.20 115200.2
Smith 0.15 88800.15
Bates 0.15 87600.15
Kumar 0.10 73200.1
Abel 0.30 132000.3
Hutton 0.25 105600.25
Taylor 0.20 103200.2
Livingston 0.20 100800.2
Grant 0.15 84000.15
Johnson 0.10 74400.1
Taylor
Fleaur
Sullivan LAST_NAME COMMISSION_PCT 12*SALARY+COMMISSION_PCT
------------------------- -------------- ------------------------
Geoni
Sarchand
Bull
Dellinger
Cabrio
Chung
Dilly
Gates
Perkins
Bell
Everett
McCain
Jones
Walsh
Feeney
OConnell
Grant
Whalen
Hartstein
Fay
Mavris LAST_NAME COMMISSION_PCT 12*SALARY+COMMISSION_PCT
------------------------- -------------- ------------------------
Baer
Higgins
Gietz 107 rows selected
你可以看到很多列是没有数据的,他们就是null
有佣金的才能用薪水加佣金显示出来
这不管是oracle还是sql,都一样
列名的别名修改
有时候列名太复杂,简写一波,或者表达式简写一波
SQL> select last_name,commission_pct as comm,12*salary + commission_pct as "annual salary" from employees;LAST_NAME COMM annual salary
------------------------- ---- -------------
King
Kochhar
De Haan
Hunold
Ernst
Austin
Pataballa
Lorentz
Greenberg
Faviet
Chen
Sciarra
Urman
Popp
Raphaely
Khoo
Baida
Tobias
Himuro
Colmenares LAST_NAME COMM annual salary
------------------------- ---- -------------
Weiss
Fripp
Kaufling
Vollman
Mourgos
Nayer
Mikkilineni
Landry
Markle
Bissot
Atkinson
Marlow
Olson
Mallin
Rogers
Gee
Philtanker
Ladwig
Stiles
Seo
Patel LAST_NAME COMM annual salary
------------------------- ---- -------------
Rajs
Davies
Matos
Vargas
Russell 0.40 168000.4
Partners 0.30 162000.3
Errazuriz 0.30 144000.3
Cambrault 0.30 132000.3
Zlotkey 0.20 126000.2
Tucker 0.30 120000.3
Bernstein 0.25 114000.25
Hall 0.25 108000.25
Olsen 0.20 96000.2
Cambrault 0.20 90000.2
Tuvault 0.15 84000.15
King 0.35 120000.35
Sully 0.35 114000.35
McEwen 0.35 108000.35
Smith 0.30 96000.3
Doran 0.30 90000.3
Sewall 0.25 84000.25LAST_NAME COMM annual salary
------------------------- ---- -------------
Vishney 0.25 126000.25
Greene 0.15 114000.15
Marvins 0.10 86400.1
Lee 0.10 81600.1
Ande 0.10 76800.1
Banda 0.10 74400.1
Ozer 0.25 138000.25
Bloom 0.20 120000.2
Fox 0.20 115200.2
Smith 0.15 88800.15
Bates 0.15 87600.15
Kumar 0.10 73200.1
Abel 0.30 132000.3
Hutton 0.25 105600.25
Taylor 0.20 103200.2
Livingston 0.20 100800.2
Grant 0.15 84000.15
Johnson 0.10 74400.1
Taylor
Fleaur
Sullivan LAST_NAME COMM annual salary
------------------------- ---- -------------
Geoni
Sarchand
Bull
Dellinger
Cabrio
Chung
Dilly
Gates
Perkins
Bell
Everett
McCain
Jones
Walsh
Feeney
OConnell
Grant
Whalen
Hartstein
Fay
Mavris LAST_NAME COMM annual salary
------------------------- ---- -------------
Baer
Higgins
Gietz 107 rows selected
annual salary中间有空格,所以需要双引号
这些东西你不用死记硬背,就那plsql操作一下,就知道了
as可以写,可以不写
SQL> select last_name,commission_pct comm,12*salary + commission_pct "annual salary" from employees;LAST_NAME COMM annual salary
------------------------- ---- -------------
King
Kochhar
De Haan
Hunold
Ernst
Austin
Pataballa
Lorentz
Greenberg
Faviet
Chen
Sciarra
Urman
Popp
Raphaely
Khoo
Baida
Tobias
Himuro
Colmenares LAST_NAME COMM annual salary
------------------------- ---- -------------
Weiss
Fripp
Kaufling
Vollman
Mourgos
Nayer
Mikkilineni
Landry
Markle
Bissot
Atkinson
Marlow
Olson
Mallin
Rogers
Gee
Philtanker
Ladwig
Stiles
Seo
Patel LAST_NAME COMM annual salary
------------------------- ---- -------------
Rajs
Davies
Matos
Vargas
Russell 0.40 168000.4
Partners 0.30 162000.3
Errazuriz 0.30 144000.3
Cambrault 0.30 132000.3
Zlotkey 0.20 126000.2
Tucker 0.30 120000.3
Bernstein 0.25 114000.25
Hall 0.25 108000.25
Olsen 0.20 96000.2
Cambrault 0.20 90000.2
Tuvault 0.15 84000.15
King 0.35 120000.35
Sully 0.35 114000.35
McEwen 0.35 108000.35
Smith 0.30 96000.3
Doran 0.30 90000.3
Sewall 0.25 84000.25LAST_NAME COMM annual salary
------------------------- ---- -------------
Vishney 0.25 126000.25
Greene 0.15 114000.15
Marvins 0.10 86400.1
Lee 0.10 81600.1
Ande 0.10 76800.1
Banda 0.10 74400.1
Ozer 0.25 138000.25
Bloom 0.20 120000.2
Fox 0.20 115200.2
Smith 0.15 88800.15
Bates 0.15 87600.15
Kumar 0.10 73200.1
Abel 0.30 132000.3
Hutton 0.25 105600.25
Taylor 0.20 103200.2
Livingston 0.20 100800.2
Grant 0.15 84000.15
Johnson 0.10 74400.1
Taylor
Fleaur
Sullivan LAST_NAME COMM annual salary
------------------------- ---- -------------
Geoni
Sarchand
Bull
Dellinger
Cabrio
Chung
Dilly
Gates
Perkins
Bell
Everett
McCain
Jones
Walsh
Feeney
OConnell
Grant
Whalen
Hartstein
Fay
Mavris LAST_NAME COMM annual salary
------------------------- ---- -------------
Baer
Higgins
Gietz 107 rows selected
咋样,as省略了,规则不变就行了,好说的这
连字运算符,||,连接字符
我们先把名字连接瞅瞅
SQL> select last_name||first_name as name from employees;NAME
---------------------------------------------
AbelEllen
AndeSundar
AtkinsonMozhe
AustinDavid
BaerHermann
BaidaShelli
BandaAmit
BatesElizabeth
BellSarah
BernsteinDavid
BissotLaura
BloomHarrison
BullAlexis
CabrioAnthony
CambraultGerald
CambraultNanette
ChenJohn
ChungKelly
ColmenaresKaren
DaviesCurtisNAME
---------------------------------------------
De HaanLex
DellingerJulia
DillyJennifer
DoranLouise
ErnstBruce
ErrazurizAlberto
EverettBritney
FavietDaniel
FayPat
FeeneyKevin
FleaurJean
FoxTayler
FrippAdam
GatesTimothy
GeeKi
GeoniGirard
GietzWilliam
GrantDouglas
GrantKimberely
GreenbergNancy
GreeneDanielleNAME
---------------------------------------------
HallPeter
HartsteinMichael
HigginsShelley
HimuroGuy
HunoldAlexander
HuttonAlyssa
JohnsonCharles
JonesVance
KauflingPayam
KhooAlexander
KingJanette
KingSteven
KochharNeena
KumarSundita
LadwigRenske
LandryJames
LeeDavid
LivingstonJack
LorentzDiana
MallinJason
MarkleStevenNAME
---------------------------------------------
MarlowJames
MarvinsMattea
MatosRandall
MavrisSusan
McCainSamuel
McEwenAllan
MikkilineniIrene
MourgosKevin
NayerJulia
OConnellDonald
OlsenChristopher
OlsonTJ
OzerLisa
PartnersKaren
PataballaValli
PatelJoshua
PerkinsRandall
PhiltankerHazel
PoppLuis
RajsTrenna
RaphaelyDenNAME
---------------------------------------------
RogersMichael
RussellJohn
SarchandNandita
SciarraIsmael
SeoJohn
SewallSarath
SmithLindsey
SmithWilliam
StilesStephen
SullivanMartha
SullyPatrick
TaylorJonathon
TaylorWinston
TobiasSigal
TuckerPeter
TuvaultOliver
UrmanJose Manuel
VargasPeter
VishneyClara
VollmanShanta
WalshAlanaNAME
---------------------------------------------
WeissMatthew
WhalenJennifer
ZlotkeyEleni107 rows selected
然后我们把薪水和名字挂起来
年薪也可以挂,然后起个别名,叫月薪和年薪
SQL> select last_name||salary as month,last_name||12*salary as annual from employees;MONTH ANNUAL
----------------------------------------------------------------- -----------------------------------------------------------------
King24000 King288000
Kochhar17000 Kochhar204000
De Haan17000 De Haan204000
Hunold9000 Hunold108000
Ernst6000 Ernst72000
Austin4800 Austin57600
Pataballa4800 Pataballa57600
Lorentz4200 Lorentz50400
Greenberg12008 Greenberg144096
Faviet9000 Faviet108000
Chen8200 Chen98400
Sciarra7700 Sciarra92400
Urman7800 Urman93600
Popp6900 Popp82800
Raphaely11000 Raphaely132000
Khoo3100 Khoo37200
Baida2900 Baida34800
Tobias2800 Tobias33600
Himuro2600 Himuro31200
Colmenares2500 Colmenares30000MONTH ANNUAL
----------------------------------------------------------------- -----------------------------------------------------------------
Weiss8000 Weiss96000
Fripp8200 Fripp98400
Kaufling7900 Kaufling94800
Vollman6500 Vollman78000
Mourgos5800 Mourgos69600
Nayer3200 Nayer38400
Mikkilineni2700 Mikkilineni32400
Landry2400 Landry28800
Markle2200 Markle26400
Bissot3300 Bissot39600
Atkinson2800 Atkinson33600
Marlow2500 Marlow30000
Olson2100 Olson25200
Mallin3300 Mallin39600
Rogers2900 Rogers34800
Gee2400 Gee28800
Philtanker2200 Philtanker26400
Ladwig3600 Ladwig43200
Stiles3200 Stiles38400
Seo2700 Seo32400
Patel2500 Patel30000MONTH ANNUAL
----------------------------------------------------------------- -----------------------------------------------------------------
Rajs3500 Rajs42000
Davies3100 Davies37200
Matos2600 Matos31200
Vargas2500 Vargas30000
Russell14000 Russell168000
Partners13500 Partners162000
Errazuriz12000 Errazuriz144000
Cambrault11000 Cambrault132000
Zlotkey10500 Zlotkey126000
Tucker10000 Tucker120000
Bernstein9500 Bernstein114000
Hall9000 Hall108000
Olsen8000 Olsen96000
Cambrault7500 Cambrault90000
Tuvault7000 Tuvault84000
King10000 King120000
Sully9500 Sully114000
McEwen9000 McEwen108000
Smith8000 Smith96000
Doran7500 Doran90000
Sewall7000 Sewall84000MONTH ANNUAL
----------------------------------------------------------------- -----------------------------------------------------------------
Vishney10500 Vishney126000
Greene9500 Greene114000
Marvins7200 Marvins86400
Lee6800 Lee81600
Ande6400 Ande76800
Banda6200 Banda74400
Ozer11500 Ozer138000
Bloom10000 Bloom120000
Fox9600 Fox115200
Smith7400 Smith88800
Bates7300 Bates87600
Kumar6100 Kumar73200
Abel11000 Abel132000
Hutton8800 Hutton105600
Taylor8600 Taylor103200
Livingston8400 Livingston100800
Grant7000 Grant84000
Johnson6200 Johnson74400
Taylor3200 Taylor38400
Fleaur3100 Fleaur37200
Sullivan2500 Sullivan30000MONTH ANNUAL
----------------------------------------------------------------- -----------------------------------------------------------------
Geoni2800 Geoni33600
Sarchand4200 Sarchand50400
Bull4100 Bull49200
Dellinger3400 Dellinger40800
Cabrio3000 Cabrio36000
Chung3800 Chung45600
Dilly3600 Dilly43200
Gates2900 Gates34800
Perkins2500 Perkins30000
Bell4000 Bell48000
Everett3900 Everett46800
McCain3200 McCain38400
Jones2800 Jones33600
Walsh3100 Walsh37200
Feeney3000 Feeney36000
OConnell2600 OConnell31200
Grant2600 Grant31200
Whalen4400 Whalen52800
Hartstein13000 Hartstein156000
Fay6000 Fay72000
Mavris6500 Mavris78000MONTH ANNUAL
----------------------------------------------------------------- -----------------------------------------------------------------
Baer10000 Baer120000
Higgins12008 Higgins144096
Gietz8300 Gietz99600107 rows selected
好玩吧
我们再给名字和jobid连接
SQL> select last_name||job_id as employee from employees;EMPLOYEE
-----------------------------------
AbelSA_REP
AndeSA_REP
AtkinsonST_CLERK
AustinIT_PROG
BaerPR_REP
BaidaPU_CLERK
BandaSA_REP
BatesSA_REP
BellSH_CLERK
BernsteinSA_REP
BissotST_CLERK
BloomSA_REP
BullSH_CLERK
CabrioSH_CLERK
CambraultSA_MAN
CambraultSA_REP
ChenFI_ACCOUNT
ChungSH_CLERK
ColmenaresPU_CLERK
DaviesST_CLERKEMPLOYEE
-----------------------------------
De HaanAD_VP
DellingerSH_CLERK
DillySH_CLERK
DoranSA_REP
ErnstIT_PROG
ErrazurizSA_MAN
EverettSH_CLERK
FavietFI_ACCOUNT
FayMK_REP
FeeneySH_CLERK
FleaurSH_CLERK
FoxSA_REP
FrippST_MAN
GatesSH_CLERK
GeeST_CLERK
GeoniSH_CLERK
GietzAC_ACCOUNT
GrantSH_CLERK
GrantSA_REP
GreenbergFI_MGR
GreeneSA_REPEMPLOYEE
-----------------------------------
HallSA_REP
HartsteinMK_MAN
HigginsAC_MGR
HimuroPU_CLERK
HunoldIT_PROG
HuttonSA_REP
JohnsonSA_REP
JonesSH_CLERK
KauflingST_MAN
KhooPU_CLERK
KingSA_REP
KingAD_PRES
KochharAD_VP
KumarSA_REP
LadwigST_CLERK
LandryST_CLERK
LeeSA_REP
LivingstonSA_REP
LorentzIT_PROG
MallinST_CLERK
MarkleST_CLERKEMPLOYEE
-----------------------------------
MarlowST_CLERK
MarvinsSA_REP
MatosST_CLERK
MavrisHR_REP
McCainSH_CLERK
McEwenSA_REP
MikkilineniST_CLERK
MourgosST_MAN
NayerST_CLERK
OConnellSH_CLERK
OlsenSA_REP
OlsonST_CLERK
OzerSA_REP
PartnersSA_MAN
PataballaIT_PROG
PatelST_CLERK
PerkinsSH_CLERK
PhiltankerST_CLERK
PoppFI_ACCOUNT
RajsST_CLERK
RaphaelyPU_MANEMPLOYEE
-----------------------------------
RogersST_CLERK
RussellSA_MAN
SarchandSH_CLERK
SciarraFI_ACCOUNT
SeoST_CLERK
SewallSA_REP
SmithSA_REP
SmithSA_REP
StilesST_CLERK
SullivanSH_CLERK
SullySA_REP
TaylorSA_REP
TaylorSH_CLERK
TobiasPU_CLERK
TuckerSA_REP
TuvaultSA_REP
UrmanFI_ACCOUNT
VargasST_CLERK
VishneySA_REP
VollmanST_MAN
WalshSH_CLERKEMPLOYEE
-----------------------------------
WeissST_MAN
WhalenAD_ASST
ZlotkeySA_MAN107 rows selected
都很简单的
这些考网警的,最基础的查询数据库的操作,你是必须要会的
不然你去做网络警察抓罪犯怎么搞?
数据库你都不会查,请问你怎么搞???
文字字符串
就是外加别的字符串
同时可以展示日期,数字
字符串和日期需要加单引号
看例子
SQL> select last_name||' is '||job_id as "employee details" from employees;employee details
---------------------------------------
Abel is SA_REP
Ande is SA_REP
Atkinson is ST_CLERK
Austin is IT_PROG
Baer is PR_REP
Baida is PU_CLERK
Banda is SA_REP
Bates is SA_REP
Bell is SH_CLERK
Bernstein is SA_REP
Bissot is ST_CLERK
Bloom is SA_REP
Bull is SH_CLERK
Cabrio is SH_CLERK
Cambrault is SA_MAN
Cambrault is SA_REP
Chen is FI_ACCOUNT
Chung is SH_CLERK
Colmenares is PU_CLERK
Davies is ST_CLERKemployee details
---------------------------------------
De Haan is AD_VP
Dellinger is SH_CLERK
Dilly is SH_CLERK
Doran is SA_REP
Ernst is IT_PROG
Errazuriz is SA_MAN
Everett is SH_CLERK
Faviet is FI_ACCOUNT
Fay is MK_REP
Feeney is SH_CLERK
Fleaur is SH_CLERK
Fox is SA_REP
Fripp is ST_MAN
Gates is SH_CLERK
Gee is ST_CLERK
Geoni is SH_CLERK
Gietz is AC_ACCOUNT
Grant is SH_CLERK
Grant is SA_REP
Greenberg is FI_MGR
Greene is SA_REPemployee details
---------------------------------------
Hall is SA_REP
Hartstein is MK_MAN
Higgins is AC_MGR
Himuro is PU_CLERK
Hunold is IT_PROG
Hutton is SA_REP
Johnson is SA_REP
Jones is SH_CLERK
Kaufling is ST_MAN
Khoo is PU_CLERK
King is SA_REP
King is AD_PRES
Kochhar is AD_VP
Kumar is SA_REP
Ladwig is ST_CLERK
Landry is ST_CLERK
Lee is SA_REP
Livingston is SA_REP
Lorentz is IT_PROG
Mallin is ST_CLERK
Markle is ST_CLERKemployee details
---------------------------------------
Marlow is ST_CLERK
Marvins is SA_REP
Matos is ST_CLERK
Mavris is HR_REP
McCain is SH_CLERK
McEwen is SA_REP
Mikkilineni is ST_CLERK
Mourgos is ST_MAN
Nayer is ST_CLERK
OConnell is SH_CLERK
Olsen is SA_REP
Olson is ST_CLERK
Ozer is SA_REP
Partners is SA_MAN
Pataballa is IT_PROG
Patel is ST_CLERK
Perkins is SH_CLERK
Philtanker is ST_CLERK
Popp is FI_ACCOUNT
Rajs is ST_CLERK
Raphaely is PU_MANemployee details
---------------------------------------
Rogers is ST_CLERK
Russell is SA_MAN
Sarchand is SH_CLERK
Sciarra is FI_ACCOUNT
Seo is ST_CLERK
Sewall is SA_REP
Smith is SA_REP
Smith is SA_REP
Stiles is ST_CLERK
Sullivan is SH_CLERK
Sully is SA_REP
Taylor is SA_REP
Taylor is SH_CLERK
Tobias is PU_CLERK
Tucker is SA_REP
Tuvault is SA_REP
Urman is FI_ACCOUNT
Vargas is ST_CLERK
Vishney is SA_REP
Vollman is ST_MAN
Walsh is SH_CLERKemployee details
---------------------------------------
Weiss is ST_MAN
Whalen is AD_ASST
Zlotkey is SA_MAN107 rows selected
瞅见了吗
中间我再额外写一个别的字符就很舒服,看起来易读
同时改名字也看起来舒服
SQL> select last_name||55||job_id as "employee details" from employees;employee details
-------------------------------------
Abel55SA_REP
Ande55SA_REP
Atkinson55ST_CLERK
纯数字中间拼就不用单引号
但是日期是要的
SQL> select last_name||'2022年10月23日'||job_id as "employee details" from employees;employee details
----------------------------------------------------
Abel2022年10月23日SA_REP
Ande2022年10月23日SA_REP
去除重复行DISTINCT
distinct就是独有的意思
部门id
SQL> desc employees;
Name Type Nullable Default Comments
-------------- ------------ -------- ------- -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
EMPLOYEE_ID NUMBER(6) Primary key of employees table.
FIRST_NAME VARCHAR2(20) Y First name of the employee. A not null column.
LAST_NAME VARCHAR2(25) Last name of the employee. A not null column.
EMAIL VARCHAR2(25) Email id of the employee
PHONE_NUMBER VARCHAR2(20) Y Phone number of the employee; includes country code and area code
HIRE_DATE DATE Date when the employee started on this job. A not null column.
JOB_ID VARCHAR2(10) Current job of the employee; foreign key to job_id column of the
jobs table. A not null column.
SALARY NUMBER(8,2) Y Monthly salary of the employee. Must be greater
than zero (enforced by constraint emp_salary_min)
COMMISSION_PCT NUMBER(2,2) Y Commission percentage of the employee; Only employees in sales
department elgible for commission percentage
MANAGER_ID NUMBER(6) Y Manager id of the employee; has same domain as manager_id in
departments table. Foreign key to employee_id column of employees table.
(useful for reflexive joins and CONNECT BY query)
DEPARTMENT_ID NUMBER(4) Y Department id where employee works; foreign key to department_id
column of the departments table
正常情况下,部门id很多重复的
SQL> select department_id from employees;DEPARTMENT_ID
-------------9090906060606060100100100100100100303030303030DEPARTMENT_ID
-------------505050505050505050505050505050505050505050DEPARTMENT_ID
-------------505050508080808080808080808080808080808080DEPARTMENT_ID
-------------8080808080808080808080808080808080505050DEPARTMENT_ID
-------------505050505050505050505050505050505010202040DEPARTMENT_ID
-------------70110110107 rows selected
去重重复的部门id,加distinct
出现在select之后紧跟distinct
然后紧跟列名
SQL> select distinct department_id from employees;DEPARTMENT_ID
-------------10030902070110508040601012 rows selected
你瞅瞅,实际上公司就12个部门,重复的就去掉了
SQL> select distinct department_id,last_name from employees;DEPARTMENT_ID LAST_NAME
------------- -------------------------50 Seo80 Cambrault80 McEwen80 Livingston50 Dellinger110 Gietz60 Austin60 Pataballa100 Popp30 Baida50 Weiss50 Fripp50 Mikkilineni50 Atkinson50 Olson50 Philtanker50 Stiles80 Bates80 Kumar50 TaylorDEPARTMENT_ID LAST_NAME
------------- -------------------------50 Sullivan50 Sarchand50 Bell60 Ernst100 Sciarra30 Himuro50 Kaufling50 Nayer50 Landry80 Russell80 Errazuriz80 Doran80 Greene80 BandaGrant50 Everett50 Feeney70 Baer110 Higgins60 Hunold100 FavietDEPARTMENT_ID LAST_NAME
------------- -------------------------30 Colmenares50 Mourgos50 Patel80 Partners80 Smith50 Fleaur50 Dilly50 Walsh50 Grant90 King30 Khoo50 Bissot50 Rogers50 Gee50 Matos80 Tucker80 Olsen80 King50 Cabrio50 McCain20 HartsteinDEPARTMENT_ID LAST_NAME
------------- -------------------------90 Kochhar90 De Haan100 Greenberg50 Ladwig80 Zlotkey80 Hall80 Sewall80 Vishney80 Ande80 Taylor80 Johnson50 Geoni40 Mavris100 Chen30 Raphaely50 Vollman50 Marlow50 Mallin50 Rajs80 Bernstein80 TuvaultDEPARTMENT_ID LAST_NAME
------------- -------------------------80 Sully80 Marvins80 Lee80 Bloom80 Fox80 Hutton50 Perkins50 Jones60 Lorentz100 Urman30 Tobias50 Markle50 Davies50 Vargas80 Ozer80 Abel50 Bull50 Chung50 Gates50 OConnell10 WhalenDEPARTMENT_ID LAST_NAME
------------- -------------------------20 Fay105 rows selected
你加上last_name
你会发现,部门又有重复了
啥意思???
其实distinct是针对的,部门id和名字,都重复的话,再去重
其实distinct是针对的,部门id和名字,都重复的话,再去重
其实distinct是针对的,部门id和名字,都重复的话,再去重
你会发现好像有2同名的人,同时在一个部门,被去掉了
因为总行数是107行
懂吧?
selcet语句小练习
请你查询这个sql语句的错误之处
咱们多练习,通过业务训练,使得自己熟悉一下这个数据
查的是employees表
第一个:
工资是salary,显然sal没有的,不能简写列名
第二个:
查询各个列之间,必须用逗号,而薪水前面是没有的
第三个:
乘法,用*,而不是×
第四个:
起别名,可以省去as,但是遇到空格和特殊字符,需要加双引号的
正确的格式如下:
SQL> select employee_id,last_name,salary*12 "annual salary" from employees;EMPLOYEE_ID LAST_NAME annual salary
----------- ------------------------- -------------100 King 288000101 Kochhar 204000
desc就是显示表结构
SQL> desc departments;
Name Type Nullable Default Comments
--------------- ------------ -------- ------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
DEPARTMENT_ID NUMBER(4) Primary key column of departments table.
DEPARTMENT_NAME VARCHAR2(30) A not null column that shows name of a department. Administration,
Marketing, Purchasing, Human Resources, Shipping, IT, Executive, Public
Relations, Sales, Finance, and Accounting.
MANAGER_ID NUMBER(6) Y Manager_id of a department. Foreign key to employee_id column of employees table. The manager_id column of the employee table references this column.
LOCATION_ID NUMBER(4) Y Location id where a department is located. Foreign key to location_id column of locations table.
然后查询所有行
SQL> select * from departments;DEPARTMENT_ID DEPARTMENT_NAME MANAGER_ID LOCATION_ID
------------- ------------------------------ ---------- -----------10 Administration 200 170020 Marketing 201 180030 Purchasing 114 170040 Human Resources 203 240050 Shipping 121 150060 IT 103 140070 Public Relations 204 270080 Sales 145 250090 Executive 100 1700100 Finance 108 1700110 Accounting 205 1700120 Treasury 1700130 Corporate Tax 1700140 Control And Credit 1700150 Shareholder Services 1700160 Benefits 1700170 Manufacturing 1700180 Construction 1700190 Contracting 1700200 Operations 1700DEPARTMENT_ID DEPARTMENT_NAME MANAGER_ID LOCATION_ID
------------- ------------------------------ ---------- -----------210 IT Support 1700220 NOC 1700230 IT Helpdesk 1700240 Government Sales 1700250 Retail Sales 1700260 Recruiting 1700270 Payroll 170027 rows selected
来源于表格
这个是employees表
我们去查信息
SQL> select employee_id,last_name,job_id,hire_date as startdate from employees;EMPLOYEE_ID LAST_NAME JOB_ID STARTDATE
----------- ------------------------- ---------- -----------100 King AD_PRES 2003/6/17101 Kochhar AD_VP 2005/9/21102 De Haan AD_VP 2001/1/13
这都好说的
这个文章的好处,就是带你一步步,学习数据库,sql语言,完整地搞定数据库
SQL> select distinct job_id from employees;JOB_ID
----------
AC_ACCOUNT
AC_MGR
AD_ASST
AD_PRES
AD_VP
FI_ACCOUNT
FI_MGR
HR_REP
IT_PROG
MK_MAN
MK_REP
PR_REP
PU_CLERK
PU_MAN
SA_MAN
SA_REP
SH_CLERK
ST_CLERK
ST_MAN19 rows selected
job分级,19级,这不就是华为的offer等级吗
jobid越高,工资越高
SQL> select last_name||', '||job_id from employees;LAST_NAME||','||JOB_ID
-------------------------------------
Abel, SA_REP
Ande, SA_REP
Atkinson, ST_CLERK
链接字符串,好说
数据操作语言DML
除查询语言之外的操作
【本节,下一篇文章继续讲】
事物处理语言TCL
事物是很重要的概念,现在简单介绍
除了查询之外,针对DML语句,他们会受到一个事物的控制,预留返回的操作
后续再说细节【本节,下一篇文章继续讲】
数据控制语言DCL
权限的授予和撤销
【本节,下一篇文章继续讲】
数据定义语言:DDL
帮助创建数据库对象
创建表啥的
【本节,下一篇文章继续讲】
总结
提示:重要经验:
1)数据查询语句,选择列,选择表,其余操作都好说
2)学好oracle,即使经济寒冬,整个测开offer绝对不是问题!同时也是你考公网络警察的必经之路。
3)笔试求AC,可以不考虑空间复杂度,但是面试既要考虑时间复杂度最优,也要考虑空间复杂度最优。
Oracle数据库:sql语言结构,数据查询语言DQL,select * from table;算术,别名,连接,去重等操作相关推荐
- oracle数据库sql培训,Oracle数据库SQL语言实战培训教程(全面、详细、案例、精讲)套餐...
风哥oracle数据库SQL语言实战培训教程(案例.精讲)套餐,DBA必备技能. 套餐介绍: 风哥Oracle数据库SQL语言实战培训教程(案例.精讲)套餐,DBA必备技能. 内容: SQL语言基础入 ...
- oracle v¥bh,ORACLE数据库sql语言、函数及常用命令
file=c:\database\ydxt200108170926.dmp log=c:\database\ydxt200108170926.log fromuser=cur touser=cur1 ...
- 数据库SQL语言学习--数据查询(持续更新中)
数据库SQL语言学习--数据查询(持续更新中) 上机练习1 1. 启动SQL Server 2008中的 SQL Server Management Studio. 2. ...
- mysql数据库tcl_MySQL数据库笔记三:数据查询语言(DQL)与事务控制语言(TCL)
完整语法格式: select 表达式1|字段,.... [from 表名 where 条件] [group by 列名] [having 条件] [order by 列名 [asc|desc]] [l ...
- mysql实验6语言结构_实验六 SQL语言数据查询语言DQL.pdf
实验六 SQL语言数据查询语言DQL 实验六 SQL 语言数据查询语言DQL 一.实验目的 数据查询语言指对数据库中的数据查询.统计.分组.排序等操作.查询语 句可以分为简单查询.连接查询.嵌套查询和 ...
- 数据库SQL语言分类(DDL/DML/DQL/TCL/DCL)
文章目录 一.数据定义语言 DDL (一)create 数据库对象的创建 (二)alter 修改数据库对象 (三)drop 删除数据库对象 (四)truncate 清空表数据 二.数据操纵语言 DML ...
- 数据库SQL语言类型(DQL.DML.DDL.DCL)
1.SQL语言 SQL(Structure Query Language)语言是数据库的核心语言. SQL是一个标准的数据库语言, 是面向集合的描述性非过程化语言. 它功能强,效率高,简单易学易维护. ...
- oracle sql 导入mysql数据库备份_使用PL/SQL连接oracle数据库,并将数据进行导出备份和导入恢复...
使用PL/SQL连接oracle数据库,并将数据进行导出备份和导入恢复 这种操作百度一搜一大片,今天整理以前做的项目时自己备份了一下数据库,试着将数据进行导出备份和导入恢复了一下:下面是操作过程: 1 ...
- Mysql数据库轻松学06—数据分析师常用:数据查询语言DQL之单表查询
数据查询语言DQL 用来查询数据库表中的记录 基本结构: SELECT 字段名 FROM 表或视图名 WHERE 查询条件 单表查询 1.结果为虚拟结果集 select语句执行后服务器会按照要求检索表 ...
最新文章
- python怎么安装numpy库-python怎么安装numpy库
- html 分割线_零基础网页设计/前端/html,第四课:前三课总结,以及单标签img
- CS231n Convolutional Neural Networks for Visual Recognition------Python Tutorial
- 控制总线上发送的控制信息
- HTML/CSS/js 日期等其他函数 相关收藏
- jsbridge实现及原理_Hybrid APP基础篇(四)-JSBridge的原理
- 好用的在线 java 编译网站,编辑器(亲测)
- python3.7中文手册chm_python3.7 官方中文手册文档全套
- Jrebel 最新激活方式
- 10倍性能提升!英伟达新卡皇降临,图灵架构GTX 20系列发布
- matlab模拟滤波器频率响应,怎样求FIR滤波器在任意频率上的频率响应?
- JavaScript 中的 Symbols 怎么用
- 微信测试号中被动消息回复的测试
- Python数据可视化-Pyecharts不同的主题风格
- Unity API——1
- WMS系统的功能,业务和定义
- 云原生—Rust编程语言能与C/C++媲美
- 数据分析案例--2012美国总统竞选赞助数据分析
- 淘宝批量下单软件 捷易淘宝批量下单软件
- P1462 通往奥格瑞玛的道路(二分 迪杰斯特拉 最短路 + spfa最短路算法)