Oracle小白进阶重点

comment on table *** is  '表的注释汉字名'
comment on column table.column is '某表的某属性后加注释';

constraint **name primary key(colum);设置主键
constraint **name foreign key(本表column) references dept(外表column);引用外键

补充表内容
alter table *** add -------   ---为类似于 constraint的这种语句,当表创建完成时,对表进行的补充

to_data('08-09-2018','dd-mm-yyyy') 类型转换,前转后
to_char 转字符串

虚标 dual
为了执行函数所使用的虚表  select to_char() from dual

模糊查询 like %
select * from dept where dname like '生%';   like代替=    %代替省略字 

排序显示
order by column_name asc/desc     不写的话默认是asc即升序,desc为降序
多列排序,即在按照第一个列排序后,再按第二列进行排序  order by column_name1,column_name2

基本函数
count求行数  sum求和  max最大 min最小 avg平均

集合操作  union 与 union all
sql  union sql2 ,必须列数相同   如果是union是去重复,如果是union all 是全部打印

序列
create    sequence    name     increment    by    x    //x为增长间隔     
                                                start    with      x    //x为初始值     
                                               maxvalue          x    //x为最大值       
                                               minvalue          x    //x为最小值     
                                               cycle                 //循环使用,到达最大值或者最小值时,从新建立对象     
                                               cache             x    //制定存入缓存(也就是内存)序列值的个数 
cache的作用:当大量语句发生请求,申请序列时,为了避免序列在运用层实现序列而引起的性能瓶颈。
Oracle序列允许将序列提前生成 cache x个先存入内存,

打印当前时间,并更改各种格式
select sysdate from dual;
select to_char(sysdate,'yyyy-mm-dd hh:mm') from dual;

过程 函数 触发器
create or replace procedure p1()
is
begin
end

create or replace function f1()
return      is
begin

return **
end


create or replace trigger t1
before delete
on emp  for each row
begin
end

几个常用的函数  ( 参考此位大佬总结https://www.cnblogs.com/xingminghui/p/7966005.html)
substr(字符串,开始位置,结束位置)用于从一段字符串里截取出一部分
NVL(x,value)   若x为空,则返回value
NVL2(x,value1,value2) 若x非空,返回value1,否则返回value2
select * from table where rownum=数字   查第几行的数据

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值