-- 表
create table test (names varchar2(12),
                   dates date,
                   num   int,
                   dou   double);
-- 视图
create or replace view vi_test as
select * from test;

-- 同义词
create or replace synonym aa
for dbusrcard001.aa;

-- 存储过程
create or replace produce dd(v_id in employee.empoy_id%type)
as
begin
   
end
dd;

-- 函数
create or replace function ee(v_id in employee%rowtype) return varchar(15)
is
var_test varchar2(15);
begin
  return var_test;
exception when others then
   
end

-- 三种触发器的定义
create or replace trigger ff
alter delete
on test
for each row
declare
begin
   delete from test;
   if sql%rowcount < 0 or sql%rowcount is null then
      rais_replaction_err(-20004,"错误")
   end if
end

create or replace trigger gg
alter insert
on test
for each row
declare
begin
   if :old.names = :new.names then
      raise_replaction_err(-2003,"编码重复");
   end if
end

create or replace trigger hh
for update
on test
for each row
declare
begin
  if updating then
     if :old.names <> :new.names then
reaise_replaction_err(-2002,"关键字不能修改")
     end if
  end if
end

-- 定义游标
declare
   cursor aa is
      select names,num from test;
begin
   for bb in aa
   loop
        if bb.names = "ORACLE" then
        
        end if
   end loop;
   
end

-- 速度优化,前一语句不后一语句的速度快几十倍
select names,dates
from test,b
where test.names = b.names(+) and
      b.names is null and
      b.dates > date('2003-01-01','yyyy-mm-dd')

select names,dates
from test
where names not in ( select names
                       from b
                      where dates > to_date('2003-01-01','yyyy-mm-dd'))

-- 查找重复记录
select names,num
from test
where rowid != (select max(rowid)
                 from test b
                where b.names = test.names and
                      b.num = test.num)

-- 查找表TEST中时间最新的前10条记录
select * from (select * from test order by dates desc) where rownum < 11

-- 序列号的产生
create sequence row_id
minvalue 1
maxvalue 8888888888888888888888
start with 1
increment by 1

insert into test values(row_id.nextval,....)

create table EMP
(
  EMPNO    NUMBER(4) not null,
  ENAME    VARCHAR2(10),
  JOB      VARCHAR2(9),
  MGR      NUMBER(4),
  HIREDATE DATE,
  SAL      NUMBER(7,2),
  COMM     NUMBER(7,2),
  DEPTNO   NUMBER(2)
)
tablespace USERS
  pctfree 10
  initrans 1
  maxtrans 255
  storage
  (
    initial 64K
    minextents 1
    maxextents unlimited
  );
comment on column EMP.EMPNO
  is '雇员编号';
comment on column EMP.ENAME
  is '雇员的名称';
comment on column EMP.JOB
  is '职位';
comment on column EMP.MGR
  is '该员工的上级的编号';
comment on column EMP.HIREDATE
  is '入职日期';
comment on column EMP.SAL
  is '薪水';
comment on column EMP.COMM
  is '奖金';
comment on column EMP.DEPTNO
  is '部门编号';
alter table EMP
  add constraint PK_EMP primary key (EMPNO)
  using index
  tablespace USERS
  pctfree 10
  initrans 2
  maxtrans 255
  storage
  (
    initial 64K
    minextents 1
    maxextents unlimited
  );
alter table EMP
  add constraint FK_DEPTNO foreign key (DEPTNO)
  references DEPT (DEPTNO);
********************************************************************

oracle--sign

取数字n的符号,大于0返回1,小于0返回-1,等于0返回0

  1. SQL> select sign(100),sign(-100),sign(0) from dual;
  2. SIGN(123) SIGN(-100)   SIGN(0)
  3. --------- ---------- ---------
  4. 1           -1         0

********************************************************************

decode 用法:

转载于:https://www.cnblogs.com/haibin168/archive/2011/02/26/1959167.html

Oracle 小知识点相关推荐

  1. Oracle小知识点之temp表空间

    温故: 上一篇文章中我和大家分享了Oracle的smon和pmon的相关知识,今天又特地来给大家讲一讲Oracle的temp表空间,为什么要讲这个呢?和昨天的理由差不多,还是有一道考试题提到了这个te ...

  2. oracle:小知识点

    一:NULL NULL不代表0,也不代表空格. NULL表示未知,无意义. 一个数+NULL结果还是NULL.  比如 1+NULL还是NULL. 二: PLSQL注释  1. --   2. /** ...

  3. oracle 常用知识点整理

    转 :  oracle 常用知识点 原文链接:http://blog.csdn.net/weijiaxiaobao/article/details/51323573 Oracle 是一个庞大的系统,里 ...

  4. 【体系结构】有关Oracle SCN知识点的整理--补充内容

    [体系结构]有关Oracle SCN知识点的整理--补充内容 小麦苗自己整理的内容参考:[体系结构]有关Oracle SCN知识点的整理  http://blog.itpub.net/26736162 ...

  5. 小知识点:ARM 架构 Linux 大数据集群基础环境搭建(Hadoop、MySQL、Hive、Spark、Flink、ZK、Kafka、Nginx、Node)

      换了 M2 芯片的 Mac,以前 x86 版本的 Linux 大数据集群基础环境搭建在 ARM 架构的虚拟机集群上有些用不了了,现在重新写一份基于 ARM 架构的,少数不兼容之外其他都差不多,相当 ...

  6. 七层登录之新小知识点

    在机房重构的时候,遇到了很多新的小知识点,初次接触,还没能灵活运用,摘出来概念性东西先来了解了解,之后再代码实现过程中希望能灵活运用! SqlHelper SqlHelper是一个基于.NET Fra ...

  7. JavaScript 小知识点

    原型链相关 最详尽的 JS 原型与原型链终极详解 isNaN() 和 Number.isNaN() 的区别 isNaN() 是 ES1 规范: 是全局方法: 如果参数不是一个 Number 类型,会先 ...

  8. Python小知识点(3)--装饰器

    Python小知识点(3)--装饰器 (1)装饰器含参数,被装饰函数不含(含)参数 实例代码如下: import time # 装饰器函数 def wrapper(func):def done(*ar ...

  9. php-函数小知识点

    <?php //语句 //分支语句 /*$a=5; if($a==5) { echo "相等";} else { echo "budeng";}*/ // ...

最新文章

  1. 1.43千米外隔墙透视!这项黑科技已被中科大潘建伟团队实现 | PNAS
  2. org.apache.catalina.connector.ClientAbortException: java.io.IOException: Broken pipe
  3. 精美日历EXCLE格式
  4. android adb server is out of date
  5. mysql常用的视图_MySQL视图
  6. mybatis动态更新xml文件后热部署,不重启应用的方法
  7. 关于vector的size()的使用问题
  8. SpringBoot使用Websocket
  9. gduuu 中旅 他最恨的是猎人
  10. php防撞库,叉车防撞预警系统的必要性
  11. 花书+吴恩达深度学习(十九)构建模型策略(训练模型顺序、偏差方差、数据集划分、数据不匹配)
  12. ODBC连接oracle 10g 客户端
  13. 计算机人员简历英语,计算机专业英文个人简历范文
  14. jquery 选择器 空格、大于、加号、波浪线区别
  15. 学习机器学习,需要具备什么的数学基础?
  16. 用微信网页版阅读文章
  17. java poi将每一个cell设置为文本格式
  18. 速卖通AE平台+聚石塔+奇门 完整教程V2
  19. SQL Leetcode练习题
  20. 使用Rational Team Concert 3.0和ODC,第2部分,提高项目质量。使用BIRT定制报告支持ODC分析...

热门文章

  1. Nginx学习4:负载均衡实例
  2. Android 活动与活动间数据传递
  3. CSS之布局(文档流)
  4. cmd查看所有数据库 db2_DB2数据库常用命令集
  5. 视频录制,压缩实现源码
  6. 03-NSPredicate谓词
  7. 分布式文件系统(FastDFS)安装 配置
  8. 《重构-改善既有代码的设计》读书笔记(二)
  9. ubuntu搭建svn、git遇到的问题及解决办法
  10. java——网络知识积累