关闭

orcle学习之路第一天

标签: orcle
85人阅读 评论(0) 收藏 举报
分类:

1.sql 语句对大小写不敏感,但在数据库中的数据却大小写敏感。对于字符型采取左对齐,数字型采用右对齐。
2.查询数据的全部信息:select * from zybrxx
3.查询不重复的数据:select distinct ksbh from zybrxx
条件表达式的运用:
4.加号:select ksbh+1 ks from zybrxx加法 ,
select ksbh+2*2-1 from zybrxx(运算顺序先乘除后加减)
5.运算顺序:select ksbh+2*2-1 newksh from zybrxx 对查询出来的数据进行重命名 (语法:列名 别名)
6.减号:select -ksbh from zybrxx (减号作为取负数运算),select (fyze-zfze )from zybrxx(作为减号运算符),如果对字符型取负,则显示查询不合法的数字,查询记录为0
7.除法运算:select fyze/2 from zybrxx
8.乘法运算:select fyze*2 from zybrxx
9.不等于;select * from ksmc where kslx <> ‘C’,select * from ksmc where kslx != ‘C’
10.Like运算:select * from ksmc where mc like ‘%科%’(找出所有mc带科的信息)
11.通配符下划线:select * from ksmc where no like ‘1‘(找出所有编号1开头的切只有2位的信息’)select * from ksmc where no like ‘_1%’(找出第二位为1的编号)信息
12.连接(||):select no ||’,’|| mc from ksmc(在编号和名称间插入1个逗号)
13.AND运算:select no ||’,’|| mc from ksmc where no >100 and xh>1
14. Or运算:select no ||’,’|| mc from ksmc where no >100 or xh>1
15. Not:select * from ksmc where mc not like’%科’,
select * from ksmc where srm1 is not null
16.(IN 和between):select * from zybrxx where cwh in(‘N03’,’N16’)
select * from zybrxx where zfze between 25 and 100
汇总函数:
17.Count:select count(brxm) from zybrxx,如果无where子句,返回所有行数
18.sum:select sum(fyze)-sum(zfze) from zybrxx(sum只能处理数字)
19.Age:select avg(fyze) from zybrxx
20.Max;select max(fyze) from zybrxx
21.Min:select minfyze) from zybrxx
22.Variance:select variance(fyze) from zybrxx
23.Stddev:select stddev(fyze) from zybrxx
时间日期函数:
24.Add_months:select zyrq,add_months(zyrq,3)as zy from zybrxx
25.Last_day:select zyrq,add_months(zyrq,3)as zy,last_day(to_date(zyrq)) as last from zybrxx
26.Sysdate:select * from zybrxx where zyrq < sysdate
数学函数
27.Abs:select abs(fyze) from zybrxx
28.Ceil:select ceil(fyze) from zybrxx
29.Floor:select floor(fyze) from zybrxx
30.Cos:select cos(fyze) from zybrxx
31.Sign:select sign(fyze) from zybrxx 参数为正返回1,为负返回-1,为0 返回0
32.Sqrt:select sqrt(fyze) from zybrxx
字符函数:
33.Concat:select concat(no,mc) as fy from ksmc字符串连接
34.Initcap:select srm1 before,initcap(srm1) after from ksmc where srm1<>’ ‘第一个字母大写,其余小写
35.Lower\upper:select lower(srm1),upper(srm1) from ksmc where srm1<>’ ’
36.Lpad:select lpad(srm1,10,’oo’) from ksmc where srm1<>’ ’
select lpad(srm1,1,’oo’) from ksmc where srm1<>’ ’
37.Rpad:select rpad(srm1,10,’oo’) from ksmc where srm1<>’ ’
38.Ltrim:select ltrim(srm1) from ksmc去掉最左边的空格
select ltrim(srm1,’K’) from ksmc where srm1<>’ ‘去掉字符串中的K
39.Rtrim:select rtrim(srm1) from ksmc去掉左右边的空格
40.Replace:select replace(srm1,’K’,’O_O’)from ksmc where srm1<>’ ‘字符串替换
41.Substr:select substr(sfzh,12,6) from zybrxx 字符截取
42.select translate(srm1,’WXZzzzz’,’211’) from zgxx单个字符的替换
43.instr:select instr(srm1,’W’,1,1) from zgxx 返回从第一个位置开始出现W的位置
44.Length:select length(sfzh) from zybrxx 返回字符串的长度
转换函数:
45.To_char():select to_char(fyze) from zybrxx
46.To_number():select to_number(ID) from zgxx
47.User:select user from zgxx返回当前使用数据库用户的名称

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:5497次
    • 积分:242
    • 等级:
    • 排名:千里之外
    • 原创:18篇
    • 转载:4篇
    • 译文:1篇
    • 评论:2条
    文章分类
    最新评论