ORACLE Rank, Dense_rank, row_number
目录
======================================================
1.使用rownum为记录排名
2.使用分析函数来为记录排名
3.使用分析函数为记录进行分组排名
一、使用rownum为记录排名:
【1】测试环境:
SQL> desc user_order;
Name Null? Type
----------------------------------------- -------- ----------------------------
REGION_ID NUMBER(2)
CUSTOMER_ID NUMBER(2)
CUSTOMER_SALES NUMBER
【2】测试数据:
SQL> select * from user_order order by customer_sales;
REGION_ID CUSTOMER_ID CUSTOMER_SALES
---------- ----------- --------------
5 1 151162
10 29 903383
6 7 &nb
相关文档:
fmobile输入参数,msg输出参数
--方法1
variable msg varchar2(100)
variable fmobile varchar2(100):='13424242890'
exec smsrun.PKG_SETNEIZHI.p_Whynomt(fmobile,msg)
print msg
--方法2
set serveroutput on;
declare
FMOBILE varchar2(100):='13424242890';
msg varchar2(100):= ......
select trim(leading | trailing | both ' ' from ' abc d ') from dual;
去掉字符串 ' abc d ' 的前面/后面/前后的空格
类似函数:ltrim, ......
DML Error Logging in Oracle 10g
主要在于使用DBMS_ERRLOG.create_error_log 这个包来跟踪dml错误信息
SQL> CREATE TABLE source (
2 id NUMBER(10) NOT NULL,
3 code VARCHAR2(10),
4 description VARCHAR2(50),
5 CONSTRAINT source_pk PRIMARY KEY (id)
6 );
表已创建。
SQL> DECLARE
2 TYPE t_tab IS ......
如何定义游标类型
TYPE ref_type_name IS REF CURSOR [RETURN return_type];
声明游标变量
cursor_name ref_type_name;
从技术底层看,两者是相同的。普通plsql cursor在定义时是“静态”的。而Ref cursors可以动态打开。
例如下面例子:
Declare
type rc is ref cursor;
cursor c is select * from dual ......
Oracle Process Structure
Oracle takes advantage of various types of processes:
—User process: Started at the time a database user requests connection to the Oracle server
—Server process: Connects to the Oracle instance and is started when a user establishes a session
& ......