摘要: CONVERT函数 一、语法 1、语法:convert(date_type,expression,style); date_type是目标数据类型,expression是源数据,style是指在数据类型转换中,可以指定样式选项,常用于时间。 2、特点 在Oracle中不可使用,在Sqlserver中 阅读全文
posted @ 2021-11-15 15:13 微风徐徐$ 阅读(783) 评论(0) 推荐(0) 编辑
摘要: 1、ORACLE没有ISNULL()函数,SQL SERVER有。 语法:ISNULL(ExprA,ExprB),ExprA是字段名,ExprB是自定义名 如果ExprA是null,就返回ExprB,否则返回ExprA 2、ORACL判断是否为空的函数是NVL 参考连接 NVL使用方法 阅读全文
posted @ 2021-11-12 17:25 微风徐徐$ 阅读(431) 评论(0) 推荐(0) 编辑
摘要: 在命令窗口输入desc可以查看表结构及相关注释 desc dba_objects; 阅读全文
posted @ 2021-11-11 21:27 微风徐徐$ 阅读(787) 评论(0) 推荐(0) 编辑
摘要: 一、DBLink的使用方法 1、DBLink的作用是通过一台服务器上面的数据库访问另外一台服务器上面的数据库 (在同一个服务器所以IP地址都一样,数据库实例分别为orcl和test,用户分别为cmh和system,现在orcl数据库(用户cmh)通过DBLink来连接test数据库的用户system 阅读全文
posted @ 2021-11-09 16:54 微风徐徐$ 阅读(13147) 评论(0) 推荐(0) 编辑
摘要: 1、oracle中有recyclebin表,用来保存用户删除的表的相关信息,相当于回收站。在recyclebin打开的情况下,用户drop掉的对象并没有被数据库删除,仍然会占用空间,除非用户手工进行purge或因为存储空间不够而被数据库清掉。 show parameter recyclebin;-- 阅读全文
posted @ 2021-11-02 23:15 微风徐徐$ 阅读(1515) 评论(0) 推荐(0) 编辑
摘要: 一、MYSQL使用limit返回指定的行数 select * from table limit m,n; //从m+1行开始返回,返回n行 select * from table limit n; //相当于select * from table limit 0,n; select * from t 阅读全文
posted @ 2021-11-01 21:45 微风徐徐$ 阅读(1136) 评论(0) 推荐(0) 编辑
摘要: 1、sql语句中判断非空不能用等号,因为null是特殊字符,必须使用关键字is和not 2、测试数据 a、测试数据 create table atest( aid varchar2(6), aname varchar2(50)) insert into atest values('1','a');i 阅读全文
posted @ 2021-10-31 21:31 微风徐徐$ 阅读(7340) 评论(0) 推荐(0) 编辑
摘要: 1、distinct用于返回唯一不同的值 2、测试 a、测试数据 create table accu ( day_code varchar2(10), buss_month varchar2(10), fnum int ) insert into accu values('20210927','20 阅读全文
posted @ 2021-10-31 19:47 微风徐徐$ 阅读(786) 评论(0) 推荐(0) 编辑
摘要: jdbc:oracle:thin:@xxx.xxx.xxx.xxx:1521:orcl jdbc:表示采用jdbc方式连接数据库 oracle:表示连接的是oracle数据库 thin:表示连接时采用thin模式(oracle有thin和oci两种方式,thin不需要安装客户端,oci需要安装客户端 阅读全文
posted @ 2021-10-26 11:51 微风徐徐$ 阅读(1642) 评论(0) 推荐(0) 编辑
摘要: datediff是SQL SERVER里面的用法,ORACLE没有 一、作用:返回两个日期之间的时间间隔 二、语法:datediff(datepart,startdate,enddate) 是后面日期减去前面的日期(enddate-startdate) 1、datepart,规定应在日期的哪一部分计 阅读全文
posted @ 2021-10-24 22:52 微风徐徐$ 阅读(37304) 评论(0) 推荐(0) 编辑
摘要: 一、substr函数 1、作用:返回截取的字段 2、语法:substr(str,begin,len) str是截取的源字段,begin是截取开始的下标,len是截取的长度;如果len>(end-begin),就会返回begin开始剩下的字符 3、测试 测试数据 select substr(day_c 阅读全文
posted @ 2021-10-24 22:43 微风徐徐$ 阅读(3465) 评论(0) 推荐(0) 编辑
摘要: 测试数据 1、where作用是将不符合where条件的行去掉,不能包含聚合函数 select * from accu where buss_month='202109' 2、having是用在分组之后过滤数据,筛选满足条件的组,条件中经常包含聚合函数 select day_code,buss_mon 阅读全文
posted @ 2021-10-24 22:22 微风徐徐$ 阅读(48) 评论(0) 推荐(0) 编辑
摘要: 集合操作前后数据集字段个数和字段数据类型要匹配(处于同一数据类型组) select employee_id,last_name,department_id from employees where department_id=30 or department_id is null; //employ 阅读全文
posted @ 2021-10-24 22:06 微风徐徐$ 阅读(238) 评论(0) 推荐(0) 编辑
摘要: 符号 || 在oracle中是连接符号,可以将两个字段的值连接在一起 举例 有一组数据 create table accu ( day_code varchar2(10), buss_month varchar2(10), fnum int ) insert into accu values('20 阅读全文
posted @ 2021-10-21 23:13 微风徐徐$ 阅读(729) 评论(0) 推荐(0) 编辑
摘要: 一、针对天的操作,适用于日、时、分、秒 1、加一天 select sysdate,sysdate+1 from dual 2、加一个小时 select sysdate,sysdate+(1/24) from dual 3、加一分钟 select sysdate,sysdate+(1/24/60) f 阅读全文
posted @ 2021-10-21 23:06 微风徐徐$ 阅读(3935) 评论(0) 推荐(0) 编辑
摘要: months_between用于计算两个日期之间相差的月数 语法:months_between(date1,date2) 举例a 20210201与20210301 select months_between(to_date('20210201','yyyy-mm-dd'),to_date('202 阅读全文
posted @ 2021-10-21 22:33 微风徐徐$ 阅读(1958) 评论(0) 推荐(0) 编辑
摘要: employees表等的创建参考链接:https://www.cnblogs.com/muhai/p/16169598.html 一、内连接inner join 只返回两个表中联结字段相等的行 1、natural join自动联结两个表中字段名和字段类型一致的所有字段,如employees表和dep 阅读全文
posted @ 2021-10-20 23:34 微风徐徐$ 阅读(564) 评论(0) 推荐(0) 编辑
摘要: 1、用法1 a、语法 decode(value,条件1,返回值1,条件2,返回值2,...,else 其他返回值),用来判断字符串是否一样 b、举例 select decode(&sex,1,'男',2,'女','其他')sex from dual 只要输入的数不是1或2都会返回 '其他' 2、用法 阅读全文
posted @ 2021-10-19 22:45 微风徐徐$ 阅读(1152) 评论(0) 推荐(0) 编辑
摘要: 一、ORACLE的NVL、NVL2、NULLIF、COALESE 1、NVL(exp1,exp2),用来判断如果字段为null就进行某些操作;如果exp1为null,返回exp2;否则返回exp1(这个函数对应MYSQL的IFNULL) select nvl(&varA,&varB) from du 阅读全文
posted @ 2021-10-19 21:56 微风徐徐$ 阅读(621) 评论(0) 推荐(0) 编辑
摘要: 1、需求: 有一表数据accu,有日、业务月、数量三个字段,业务月是指上个月28号至当月27号。 通过日累计求和得到某一天的业务月累计数量。例如 20211001 这一天的月累计是20210928-20211001的日数量求和得到的。 2、表数据 create table accu ( day_co 阅读全文
posted @ 2021-10-17 23:32 微风徐徐$ 阅读(1011) 评论(0) 推荐(0) 编辑