Oracle数据库知识总结

一、Sql语句

1.1 查询语句

  1. order排序(其中含有null)
    查询雇员的奖金并做降序排序(关于nulls first/nulls last)
    select ename, comm from emp order by comm desc nulls last;

    其中null的数据排序默认为nulls first 排在前面

创建自动增长序列

-- 创建自动增长序列
CREATE SEQUENCE INCREASE_SEQUENCE_A
INCREMENT BY 1
START WITH 1
NOMAXVALUE
NOCYCLE
CACHE 10;

-- 创建触发器
CREATE TRIGGER A BEFORE
INSERT ON A FOR EACH ROW WHEN(NEW.SEQNO IS NULL)
BEGIN
  SELECT INCREASE_SEQUENCE_A.NEXTVAL INTO:NEW.SEQNO FROM DUAL;
END;
 
INSERT INTO A(AGENTCODE,ASSESSTYPE,Yearmonth,Actualcheckdays,Managecom) VALUES('G1241213','01','202011',12.12,'860012')
INSERT INTO A(AGENTCODE,ASSESSTYPE,Yearmonth,Actualcheckdays,Managecom) VALUES('G1241213','01','202011',12.12,'860012')
©️2020 CSDN 皮肤主题: 数字50 设计师:CSDN官方博客 返回首页