标签云
asm恢复 bbed bootstrap$ dul In Memory kcbzib_kcrsds_1 kccpb_sanity_check_2 kfed MySQL恢复 ORA-00312 ORA-00607 ORA-00704 ORA-01110 ORA-01555 ORA-01578 ORA-08103 ORA-600 2131 ORA-600 2662 ORA-600 2663 ORA-600 3020 ORA-600 4000 ORA-600 4137 ORA-600 4193 ORA-600 4194 ORA-600 16703 ORA-600 kcbzib_kcrsds_1 ORA-600 KCLCHKBLK_4 ORA-15042 ORA-15196 ORACLE 12C oracle dul ORACLE PATCH Oracle Recovery Tools oracle加密恢复 oracle勒索 oracle勒索恢复 oracle异常恢复 Oracle 恢复 ORACLE恢复 ORACLE数据库恢复 oracle 比特币 OSD-04016 YOUR FILES ARE ENCRYPTED 勒索恢复 比特币加密文章分类
- Others (2)
- 中间件 (2)
- WebLogic (2)
- 操作系统 (102)
- 数据库 (1,686)
- DB2 (22)
- MySQL (74)
- Oracle (1,548)
- Data Guard (52)
- EXADATA (8)
- GoldenGate (24)
- ORA-xxxxx (159)
- ORACLE 12C (72)
- ORACLE 18C (6)
- ORACLE 19C (15)
- ORACLE 21C (3)
- Oracle 23ai (7)
- Oracle ASM (68)
- Oracle Bug (8)
- Oracle RAC (53)
- Oracle 安全 (6)
- Oracle 开发 (28)
- Oracle 监听 (28)
- Oracle备份恢复 (566)
- Oracle安装升级 (92)
- Oracle性能优化 (62)
- 专题索引 (5)
- 勒索恢复 (80)
- PostgreSQL (18)
- PostgreSQL恢复 (6)
- SQL Server (27)
- SQL Server恢复 (8)
- TimesTen (7)
- 达梦数据库 (2)
- 生活娱乐 (2)
- 至理名言 (11)
- 虚拟化 (2)
- VMware (2)
- 软件开发 (37)
- Asp.Net (9)
- JavaScript (12)
- PHP (2)
- 小工具 (20)
-
最近发表
- .hmallox加密mariadb/mysql数据库恢复
- 2025年首个故障恢复—ORA-600 kcbzib_kcrsds_1
- 第一例Oracle 21c恢复咨询
- ORA-15411: Failure groups in disk group DATA have different number of disks.
- 断电引起的ORA-08102: 未找到索引关键字, 对象号 39故障处理
- ORA-00227: corrupt block detected in control file
- 手工删除19c rac
- 解决oracle数据文件路径有回车故障
- .wstop扩展名勒索数据库恢复
- Oracle Recovery Tools工具一键解决ORA-00376 ORA-01110故障(文件offline)
- OGG-02771 Input trail file format RELEASE 19.1 is different from previous trail file form at RELEASE 11.2.
- OGG-02246 Source redo compatibility level 19.0.0 requires trail FORMAT 12.2 or higher
- GoldenGate 19安装和打patch
- dd破坏asm磁盘头恢复
- 删除asmlib磁盘导致磁盘组故障恢复
- Kylin Linux 安装19c
- ORA-600 krse_arc_complete.4
- Oracle 19c 202410补丁(RUs+OJVM)
- ntfs MFT损坏(ntfs文件系统故障)导致oracle异常恢复
- .mkp扩展名oracle数据文件加密恢复
分类目录归档:Oracle 开发
GREATEST/LEAST函数
GREATEST
greatest( expr1, expr2, … expr_n )
expr1, expr2, . expr_n 可以是值也可以是函数.
函数功能: 取得值最大值
SQL> SELECT GREATEST(10,21,3,15,18) FROM dual;
GREATEST(10,21,3,15,18)
———————–
21
SQL> SELECT GREATEST(‘abc’,’bca’,’cba’,’bac’,’cabb’,’cbaa’) FROM dual;
GREATEST(‘ABC’,’BCA’,’CBA’,’BA
——————————
cbaa
LEAST
least( expr1, expr2, … expr_n )
expr1, expr2, . expr_n 可以是值也可以是函数.
函数功能: 取得值最小值
SQL> SELECT least(10,21,3,15,18) FROM dual;
LEAST(10,21,3,15,18)
——————–
3
SQL> SELECT least(‘abc’,’bca’,’cba’,’a’,’bac’,’cabb’,’cbaa’) FROM dual;
LEAST(‘ABC’,’BCA’,’CBA’,’A’,’B
——————————
a
发表在 Oracle 开发
评论关闭
oracle分割函数
1、创建varry
CREATE OR REPLACE TYPE Varchar2Varray IS VARRAY(100) of VARCHAR2(40);
2、创建分割函数
CREATE OR REPLACE FUNCTION f_strsplit (STRING VARCHAR2, substring VARCHAR2) RETURN varchar2varray IS len INTEGER := LENGTH (substring); lastpos INTEGER := 1 - len; pos INTEGER; num INTEGER; i INTEGER := 1; ret varchar2varray := varchar2varray (NULL); v_str VARCHAR2 (20); /**自定义split函数,将指定的字符串按指定的标志符分割成字符数组*/ BEGIN LOOP pos := INSTR (STRING, substring, lastpos + len); IF pos > 0 THEN --found num := pos - (lastpos + len); ELSE --not found num := LENGTH (STRING) + 1 - (lastpos + len); END IF; IF i > ret.LAST THEN ret.EXTEND; END IF; v_str := SUBSTR (STRING, lastpos + len, num); --DBMS_OUTPUT.put_line (v_str); ret(i) := v_str; EXIT WHEN pos = 0; lastpos := pos; i := i + 1; END LOOP; RETURN ret; END;
3、调用
select * from tab_dailyreport_user where user_id in ( SELECT * FROM ( TABLE( select f_strsplit(user_invite,',') from tab_dailyreport_user t where t.user_id = 168148)));
说明:主要是改写开发提过来的一个sql语句的帮助
select * from tab_dailyreport_user where user_id in ( --'166445','164216','171128','184427','160113','160133','160134','160138','160144','160163','160587','166457','167914','168076','168192','168997','169842','169901','184407','184747','185089','185130','208134','208141','208143','208183','160142','166455','167838','168074','168194','168666','185088','185138','185145','208103','169844','171071','160107','166421','166874','168193','179871','179872','184096','184228','184232','184269','184774','184969','185111','207871','160167','161813','14880','134','164355','168149') select substr(regexp_replace,3,length(regexp_replace)-4) from ( select regexp_replace((select user_invite from tab_dailyreport_user t where t.user_id = 168148), '(,)', chr(39)||','||chr(39)) regexp_replace from dual) )
括号里面的语句查询出来的结果是注释部分,直接使用注释的部分在in中可以查询,如果使用里面的语句不能查询,他们的需求是想把外面的user_id在里面的语句中的,可是oracle会把里面的in查询出来的结果作为一个整体,从而出现number类型不能和varchar类型匹配的提示,采用方法是分割in里面查询出来的语句,然后类型转换为table进行查询。
关于日期sql语句
网友请求写几条关于日期的sql语句
1、查询两个日期天数
select trunc(to_date(to_date( ’2004-3-20 ‘, ‘yyyy-mm-dd ‘)-to_date( ’2004-3-25 ‘, ‘yyyy-mm-dd ‘),’mm’) ) from dual ;
–trunc函数不用也行,因为日期格式化就是到天
2、查询两个日期的月份
SELECT trunc(months_between(to_date( ’2004-3-20 ‘, ‘yyyy-mm-dd ‘),SYSDATE)) FROM dual;
–根据需求是截断还是取近似值决定使用floor或者trunc
3、根据生日查询年龄
1)计算年龄(周岁)
select floor(months_BETWEEN(SYSDATE,to_date( ’2004-4-25 ‘, ‘yyyy-mm-dd ‘))/12) FROM dual;
2)计算年龄(虚岁)
SELECT to_char(SYSDATE,’yyyy’)-to_char(to_date(’2004-03-04′,’yyyy-mm-dd’),’yyyy’) FROM dual;
主要就是trunc(近似值)和floor(截断)函数使用
发表在 Oracle 开发
评论关闭