PLSQL常用语句汇总

PLSQL常用语句汇总

ID:38260199

大小:23.44 KB

页数:7页

时间:2019-06-07

PLSQL常用语句汇总_第1页
PLSQL常用语句汇总_第2页
PLSQL常用语句汇总_第3页
PLSQL常用语句汇总_第4页
PLSQL常用语句汇总_第5页
资源描述:

《PLSQL常用语句汇总》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、PLSQL常用语句汇总在SQLPLUS下,实现中-英字符集转换altersessionsetnls_language='AMERICAN';altersessionsetnls_language='SIMPLIFIEDCHINESE';主要知识点:一、有关表的操作1)建表createtabletestasselect*fromdept;--从已知表复制数据和结构createtabletestasselect*fromdeptwhere1=2;--从已知表复制结构但不包括数据2)插入数据:insertintotestse

2、lect*fromdept;二、运算符算术运算符:+-*/可以在select语句中使用连接运算符:

3、

4、selectdeptno

5、

6、dnamefromdept;比较运算符:>>==!=<<=likebetweenisnullin逻辑运算符:notandor集合运算符:intersect,union,unionall,minus要求:对应集合的列数和数据类型相同查询中不能包含long列列的标签是第一个集合的标签使用orderby时,必须使用位置序号,不能使用列名例:集合运算符的使用:intersect,union,unio

7、nall,minusselect*fromempintersectselect*fromempwheredeptno=10;select*fromempminusselect*fromempwheredeptno=10;select*fromempwheredeptno=10unionselect*fromempwheredeptnoin(10,20);--不包括重复行select*fromempwheredeptno=10unionallselect*fromempwheredeptnoin(10,20);--包括重

8、复行三,常用ORACLE函数sysdate为系统日期dual为虚表一)日期函数[重点掌握前四个日期函数]1,add_months[返回日期加(减)指定月份后(前)的日期]selectsysdateS1,add_months(sysdate,10)S2,add_months(sysdate,5)S3fromdual;2,last_day[返回该月最后一天的日期]selectlast_day(sysdate)fromdual;3,months_between[返回日期之间的月份数]selectsysdateS1,month

9、s_between('1-4月-04',sysdate)S2,months_between('1-4月-04','1-2月-04')S3fromdual4,next_day(d,day):返回下个星期的日期,day为1-7或星期日-星期六,1表示星期日selectsysdateS1,next_day(sysdate,1)S2,next_day(sysdate,'星期日')S3FROMDUAL5,round[舍入到最接近的日期](day:舍入到最接近的星期日)selectsysdateS1,round(sysdate)S

10、2,round(sysdate,'year')YEAR,round(sysdate,'month')MONTH,round(sysdate,'day')DAYfromdual6,trunc[截断到最接近的日期]selectsysdateS1,trunc(sysdate)S2,trunc(sysdate,'year')YEAR,trunc(sysdate,'month')MONTH,trunc(sysdate,'day')DAYfromdual7,返回日期列表中最晚日期selectgreatest('01-1月-04',

11、'04-1月-04','10-2月-04')fromdual二)字符函数(可用于字面字符或数据库列)1,字符串截取selectsubstr('abcdef',1,3)fromdual2,查找子串位置selectinstr('abcfdgfdhd','fd')fromdual3,字符串连接select'HELLO'

12、

13、'helloworld'fromdual;4,1)去掉字符串中的空格selectltrim('abc')s1,rtrim('zhang')s2,trim('zhang')s3fromdual2)去掉前导和后

14、缀selecttrim(leading9from9998767999)s1,trim(trailing9from9998767999)s2,trim(9from9998767999)s3fromdual;5,返回字符串首字母的Ascii值selectascii('a')fromdual6,返回ascii值对应的字母selectch

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。