




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、oracle-9i sql(structuredquerylanguage,结构化查询语言)SQL语言按照功能可分为4大类*DQL(数据查询语言):查询*DDL(数据定义语言)建立/删除和修改费对象*DML(数据操纵语言):完成操作的命令,包括查询*DCL(数据控制语言)控制对数据库的访问,服务器的关闭/启动等在0acle9i中为使用SQL语言提供了 2个主要工具*SQLPIus*SQLPIusWorksheet select*fomscott.emp-用户名.数据君的形式selectdistinctjobfromscott.emp-distinct保留字指在显示时去除相同的记录,select
2、empno/enamejobfromscottempwherejob=MANAGERselectempnofenamersalfromscott.empwheresal=2500-等于select*fromscott.empwherejob=,MANAGER,select*fromscott.empwheresal=1100-不等于select*fromscott.empwherejob!=,MAN AGER1select*fromscott.empwheresal! = 1100select*fromscott.empwherejobA=,MANAGERselect*fromscott.em
3、pwheresalA = 1100select*fromscott.empwherejobMAN AGERselect*fromscott.empwheresal 1100一小于select*fromscott.empwherejobMANAGER select*fromscott.empwheresalMANAGER select*fromscott.empwheresal2000-int列表select*fromscott.empwheresalin(2000,1000,3000) select*fromscott.empwherejobin(MAN AGER,CLERK) select*
4、fromscott.empwheresalnotin(2000,1000,3000) selecCfromscott.empwherejobnotinCMANAGERJCLERK) -betweenselect*fromscott.empwheresalnotbetween2000and3000selecCfromscott.empwherejobnotbetweenMANAGERandCLERKlikeselect*fromscott.empwherejoblike%M%-代表包含 M 的字符串 select*fromscott.empwherejoblike%M-代表以 M 字符结尾的字符
5、串 selectHromscott.empwherejoblikeM%-代表以 M 字符开头的字符串 selectHromscott.empwherejoblikeM-代表M开头的长度为2的字符串 selectempno,ename,jobfromscottempwherejob = CLERKorsal=2000 notjob二,CLERK割介于joboCLERK 一逻辑比较符and(-)select*fromscott.empwherejob=MANAGERandsal2000 or(或)select*fromscott.empwherejob ! =MANAGERorsal2000 no
6、t(菲)select*fromscott.empwherenotjob=MANAGER一排序查询selectempnorenamejobrsalfromscott.empwherejob = ,CLERK,orderbyjobasc/saldesc 一分组查询selectempnofenamejoblsalfromscott.empgroupbyjob/empnofenamelsalhavingsal=2000 selectempno/enamejobrsalfromscott.empwheresal=(selectsalfomscottempwhereename =WARD)查询薪水=/人区
7、口 薪水的员工selectemp.empno.emp.ename.emp.job.emp.salfromscott.empwheresdlin(selectsalfromscott.empwhereename =WARD) -查询薪水和 WARD 相等的员工带any查询selectemp.empno.emp.ename.emp.job.emp.salfromscott.empwheresalany(selectsalfromscott.empwherejob=lMANAGER,)/*selectsalfromscott.empwherejob:MANAGER查询至ij 3 各薪水值 2975/
8、2850/2450selectemp.empno.emp.ename.emp.job.emp.salfromscott.empwheresal2975orsal2850orsal2450一四亍 any 查询条件语句*/带some查询selectemp.empno.emp.ename.emp.job.emp.salfromscott.empwheresal=some(selectsalfromscott.empwherejob=MAN AGER)/*selectsalfr。mscott.empwherejob:MANAGER-查询到 3 各薪水值 2975/2850/2450selectemp.
9、empno.emp.ename.emp.jobemp.salfromscott.empwheresal=2975orsal=2850orsal=2450期亍 some 查询条件语句*/带all查询selectemp.empno.emp.ename.emp.jobemp.salwheresalall(selectsalfromscott.empwherejob=,MANAGER,)sdectsalfromscott.empwherejob=MANAGER一查询到 3 各薪水值 2975/2850/2450selectemp.empno.emp.ename.emp.job.emp.salfroms
10、cott.empwheresal2975andsal2850andsal2450一执行 all 查询条彳牛语句*/带exists查询selectemp.empno.emp.enamemp.job.emp.salfromscott.emp,scott.deptwhereexists(select*fromscott.empwherescott.emp.deptno=scott.dept.deptno)并操作查询(selectdeptnofromscott.emp)union(selectdeptnofromscott.dept)交操作查询(selectdeptnofromscott.emp)in
11、tersect(selectdeptnofromscott.dept)差操作查询-属于A且不属于B(selectdeptnofromscott.emp)minus(selectdeptnofromscott.dept)-用SQL进行函数查询ceil函数:ceil(n),取大于等于数值n的最小整数 selectmgGmgt/lOOeiKmgr/lOOJfromscott.empfloor函数:floor(n),取小于等于数值n的最大整数selectmgcmgt/lOOJIoorfmgr/lOOJfromscott.empmod函数:mod(m,n),取m整除n后的余数selectmgr/mod(
12、mgr/1000)/mod(mgrl100),mod(mgr,10)fromscott.emppower函数:powe(m,n),取 m 的 n 次方selectmgr;power(mgn2)fpower(mgr3)fromscott.empround函数round(m,n),四舍五入,保留n位 selectmgr,ound(mgr/100,2),round(mgr/1000,2)fromscott.empsign函数:sign(n),n0,取 l;n=0,取 0;n =6999);-表间数据复制createtable语句的功能就是创建新的 createtablescott.testselectdistinctempno.ename.hiredate fromscott.emp whereempno =7000一删除数据 使用delete命令可以删除数据,数据将存储在系统回滚段中,需要的时候可以回滚恢复;不可恢复.使用truncate命令可以删除整表数据但保留结构,deletefrom表where条件deletefromscott.testwhereempno =7500andempno =8000;truncatetablescott.test;-更新数
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 项目十七装载机工作装置的检测与修复任务1结构件的拆装与调整
- 斜二轴测图不改变原物体与投影面的相对位置物体正放改变投射线
- 无侧限抗压强度试验赵凤杰四川交通06课件
- 为了保证行车安全和必要的线路通过能力铁路上每隔一定距离10
- 教育行业教育虚拟现实报告:VR技术在教育领域的创新应用
- 2025年主题公园沉浸式体验项目开发与景区经济效益分析报告
- 2025年特色农产品冷链物流中心冷链物流行业冷链物流行业产业链整合建议
- 自我牵伸康复
- 眩晕症的中医护理常规
- 冬天里的哈气活动
- 国家开放大学电大《水利水电工程建筑物》期末题库及答案
- 【培训课件】管理沟通
- 2024-2030年中国外资医院行业发展现状及投资管理模式分析报告
- 停车场环境卫生保洁方案
- 管道直饮水项目可行性研究报告
- 《公路桥梁挂篮设计与施工技术指南》
- 期中复习-首字母填空精练100题 2024-2025学年人教版英语八年级上册
- 临床富血小板血浆介绍、分类、制备技术及质量控制要点
- 2024年地铁施工负责人安全考试题库-判断题
- 人教版历史2024年第二学期期末考试七年级历史试卷(含答案)
- 大药房《质量管理体系文件》-管理制度
评论
0/150
提交评论