- 博客(44)
- 资源 (2)
- 收藏
- 关注
原创 hive 解析json 之 json 中(key 不确定名称及个数, values 不确定数值及个数) 情况下解析
json 串如下所显示 repayment list 中,有 多个 maps ,其中个maps中的key 是不确定个数的,半年是7个,2个月就是3个. "repayment":{"credit_rpy_amt":{"2018-11":"0.00","2018-10":"0.00","2018-09":"0.00","
2018-11-30 17:40:44
6603
原创 016-mha模式配置
描述:MHA(Master High Availability),目前mysql中比较常用的解决方案。工具:masterha_check_ssh 检查MHA的SSH配置状况masterha_check_repl 检查MySQL复制状况masterha_manger 启动MHAmasterha_chec
2017-07-12 15:36:39
485
原创 oracle keep函数
select id, mc, sl, min(mc) keep(DENSE_RANK first ORDER BY sl) over(partition by id) a1,-- sl中最小中,取mc最小 max(mc) keep(DENSE_RANK last ORDER BY sl) over(partition by id) a2,--
2017-03-01 15:29:03
531
原创 打开一个txt文件,读取里面的内容并打印出来
#!E:\Dwimperl\binopen(FILEIP, "E:/Dwimperl/program/test/file3.txt"); ### 打开别的盘的文件while(){ chomp ; # 去除换行 s/00000//ig; print $_."\n"; }close (FILEIP)my $file = "file.tx
2017-01-04 16:57:06
5279
原创 调用windows set命令,查找 环境变量中带有java的环境变
my $now=`date`.`time`;print "the time is now $now.\n";my $who_text=`set`;my @who_lines=`set`;print "----------------------------------------------------\n";my $num=$#who_lines; my $i=0;for ($i
2017-01-04 16:55:54
318
原创 perl-指定目录下面修改某文件的名字及修改此文件中的内容
#!/usr/bin/perl -w use strict ; chomp(my $date=`date`);@ARGV=glob "aa.dat" or die "no files found";$^I=".bak";while ( { s/^aaa:*/aaa:change value/; s/^bbb:.*\n//; s/^ccc:.*/ccc:$date/; print ; }
2017-01-04 16:54:02
1632
原创 perl 生成SQL语句
如上图显示,在公司每当起一个新项目时,都需要分析一些常用字段,及字段类型、字段长度。那分析完后,要需要对数据库进行相应的建表操作了,当然现在有很多工具,比如:powerdesin、ERwin之类的建模工具能省任,那比如公司给提供了一个类似excel这类的数据,用手工来完成,这太费事了,所以才有这个想法。使用Perl脚本,对excel进行读取操作,然后根据相应的格式,生成对应的SQL语句。#
2016-12-21 15:09:44
2523
原创 正则表达式 例子
#! /usr/bin/perl –wmy $what = "fred|test"; # 在此处。| 相当于或的意思while(<>){if(/^($what)/){ # 匹配行开头是 fred或test的数据,如果是,通过 ifprint "We saw $what in beginning of $_;";}}利用正则:my $line = 'how old are yo
2016-12-19 14:45:25
207
原创 正则表达式 常用的正则
/yes/i # 匹配 yes的 不区分大小写/s # 匹配 任何字符/x # 添加空格 /U #要求紧接着的都是大写/L #要求后面的全部是小写 -? #可选的负号\d+ #小数点前一个或多个十进制数字\.? #可选的小数点\d* #小数点后一些可选的十进制数字/x #模式结束 /\bfred/b\ # 匹配 fred 只能/\bhunt/ #将匹配 hun
2016-12-19 14:43:48
286
原创 写一个名为 &total 的子程序,返回一列数字的和
sub total { my $sum=0; foreach (@_) { $sum=$sum+$_; } $sum; } my @fred = 1 .. 1000 ;$fred_total=&total(@fred);print $fred_total,"\n";
2016-12-19 14:42:05
633
原创 调用子程序来返回 某个字段在数组中的位置
my @names = qw / fred test dfdf dino abcde/;my $result=&max("dino",@names);sub max { my($what,@array)=@_; foreach(0..$#array) { if ($what eq $array[$_]) { return $_+1; } } -1; }
2016-12-14 18:14:29
431
原创 ($m)与$m 变量 赋值时要注意的地方
#!/user/bin/perl@m=qw / bcddd b c d e f g /;($x)=@m; #### 这种操作得到 数组中 第一组 数 $y=@m; #### 这种操作奖得到数组中,有几个变量的个数print $x,"\n";print $y,"\n";print $x[0],"\n";print @m,"\n";print $m[1],"\n";#!/us
2016-12-14 18:13:27
794
原创 读取几行数据,反向显示
#!/user/bin/perlprint "enter some lines, then press ctrl+Z \n";@lines=<>;@reverse_line= reverse @lines;print @reverse_line;
2016-12-14 18:12:39
340
原创 splice的用法
#!/user/bin/perl@array=qw ( pebbles dino fred barney betty);@removed=splice @array ,1,2,qw (abc bcd def);print @removed,"\n";print @array ,"\n";
2016-12-14 18:11:55
455
原创 scalar 函数的使用
#!/user/bin/perl@rocks=qw( talc quartz jade obsidian);print "How many rocks do you have ?\n";print "i have ",@rocks," rocks!\n";print "i have ",scalar @rocks , " rocks!\n"; #print @rocks+1-1;#s
2016-12-14 18:11:21
10132
原创 each的用法及while 的使用方法
#!/user/bin/perlmy @rocks = qw / bedrock salate rubble granite / ; while (my( $index,$value)= each @rocks){ print "$index: $value \n"; } print "哈哈:\n"; #两种相同的写法foreach $index (0 .
2016-12-14 18:10:19
527
原创 查看本机中所有perl已经安装的模块
在学习perl中,经常会下载一些模块,有些模块本来已经存在,因为刚学习,并不知道这些模块的名称及作用,所以需要打印出来,又因为安装的模块太多,打印出来的东西太多,看的不是很连惯,所以要使用以下命令操作:windowns 如下操作: C:\Users\user>perldoc perllocal >d:\1.txt这把就把文件信息保存到D盘下的1.txt文件中。我们再
2016-12-09 11:01:49
3238
原创 显示一个目录内所有文件,及有条件的过滤某些文件
#!/usr/bin/perl opendir (DIR,'./test/test') or die "Cont't open directory,$!";while ($file=readdir DIR) { print "$file\n"; ## 打开一个目录,并列了目录内的所有文件 } closedir DIR;print "*************************
2016-12-05 18:29:11
503
原创 oracle regexp_instr
oracle中使用正则:select distinct regexp_instr('12345612345123', '123', LEVEL, 1) FROM DUAL WHERE regexp
2016-06-22 16:57:42
675
原创 mysql 用户自定义变量
首先推荐一个博客:http://blog.itpub.net/29254281/viewspace-1415038/这里面详细的介绍了怎么使用自定义变量 ,我这里本是发出一些疑问:一、 set @rownum:=0;select disease,rn,@rownum,@rownum:=@rownum+1 as cmt from disease_code where @rownu
2016-01-26 17:30:05
1350
2
原创 mysql 一行转多行
最近刚开始学mysql ,网上开始找mysql 开发的习题,现有这个:实现方法:select tid,bdate,edate,DATE_ADD(bdate,INTERVAL b.help_topic_id MONTH) ,b.help_topic_id+1 from (select 'a1' tid, DATE_FORMAT('2014-07-15','%Y-
2016-01-19 18:01:01
5869
1
原创 mysql 实现 oracle 中 rorw_number() over () 函数
drop table if exists heyf_t10; create table heyf_t10 (empid int ,deptid int ,salary decimal(10,2) ); insert into heyf_t10 values (1,10,5500.00), (2,10,4500.00), (3,20,1900.00), (4,20,4800.
2016-01-13 09:56:49
978
原创 coalesce 函数的使用方法,
需求:表中有三列: mobile1,mobile2,mobile3 ,三列电话只,如果mobile1为空,使用mobile2,如果mobile2 也为空,使用mobile3,select coalesce(mobile1,replace(mobile2,' ',''),mobile3) mobile ,mobile1,mobile2,mobile3 from ods_customer_idv_
2014-03-21 11:41:54
1009
原创 SQL日常使用小方法:
一、去重复,没要求,只要求保单号相同记录的第一条记录,其它的不考虑select * from (select row_number () over (partition by policyno order by proposalno) rn,t.* from ods_cmain_all t where t.policyno='0120121101060060201
2014-03-20 10:31:32
401
原创 SQL;一列转多行的使用 --正则表达式的使用
需求:1policyno(保单号)列:0210130626000335001565/0211130626000332002226/0211130626000332002227/0211130626000332002227/0211130626000332002229/0211130626000332002210这是由多个保单号组成:需要整理成多行:policyno 021013
2014-03-20 10:20:49
842
原创 查找某个用户下的表,某个用户下某个表的列,及列类型
查找某个用户下的表,某个用户下某个表的列,及列类型 一、user_tables; select * from user_tables;二、user_tab_columsselect * from user_tab_columns where TABLE_NAME='ODS_PHEAD'; 作用:查找某个用户下面某个表下面某列是什么类型的,多长,等
2014-03-18 10:35:11
460
原创 SQLloader 导入文本字段有中特别符号的操作方法
导出生成落地文件的脚本:SELECT policyno 保单号, tsid 投诉id, aplname 投诉人姓名, aplmobile 投诉人手机, TO_CHAR (apldate, 'yyyy-mm-dd hh24:mi:ss') 投诉时间, apltype 投诉类型, ASCIISTR (replace
2013-12-26 10:49:40
2064
原创 oracle 新功能model子句的简单使用
使用版本:>= 10G一、建立测试表-----------建立测试表 CREATE TABLE SALE_REPORT ( SALE_DATE DATE NOT NULL , SALE_ITEM VARCHAR(2) NOT NULL , SALE_MONEY DECIMAL(10,2) NOT NULL )二、测试
2013-09-16 10:34:31
729
原创 另类的ORACLE分析函数over(partition by...)
oracle 分析函数使用的另类:over (partition by ......) 分析函数中使用case when ;例:SQL> with pctest as ( 2 SELECT 1 id ,'a1' name from dual 3 union 4 SELECT 1 id ,'a2' name from dual 5 union 6
2013-09-13 14:29:02
696
1
原创 一行转多行效果(一)
一行转多行效果显示:SQL> with test as ( select 'a',4,10 from dual union select 'b',2,8 from dual) select * from test;'A' 4 10--- ---------- ----------a 4
2013-09-05 11:46:48
419
原创 分析函数sum() over (order by ) 使用记录
环境:oracle 10.2.0.1.0用户:scott / tiger分析函数sum() over (order by ) 使用记录:SQL> select ename,sal,sum(sal) over(order by sal,empno) from emp order by 2;ENAME SAL SUM(SAL)OVER(ORDERBYSAL,
2013-09-03 16:34:19
5747
原创 求某个用户下个有多少表,每表个中的多少行。
求某个用户下个有多少表,每表个中的多少行。以及求oracle 数据库认为表有多少行,实行表中有多少表。创建表 COUNTROWScreate table countrows as select owner, table_name, tablespace_name, num_rows, num_rows new_rows from dba_tables s
2013-08-16 17:37:16
544
原创 游标的个人使用理解
---------------静态显式游标 declare cursor A_cursor is select * from emp; ---直接声明游标begin for emp_rec in A_cursor loop dbms_output.put_line(emp_rec.ename || emp_rec.empno || emp_rec.sal
2013-08-16 16:54:23
743
原创 1.1.1.2. coalesce 函数
coalesce 函数是用实际值来替换空值: SQL> select comm from emp; COMM--------- 300.00 500.00 1400.00 0.0014 rows selectedSQL> 使用coalesce :SQL> select coalesce(comm,123
2013-08-15 10:17:35
377
原创 wmsys.wm_concat( ) 常用的使用方法
SQL> select deptno,ename from emp; DEPTNO ENAME------ ---------- YODA 20 SMITH 30 ALLEN 30 WARD 20 JONES 30 MARTIN 30 BLAKE 10 CLARK 10 KING
2013-07-16 17:15:42
740
原创 SYS_CONNECT_BY_PATH()与start with ... connect by priod 的用法~~
一、 start with ... connect by priod 的使用方法介绍: SQL> SELECT level, empno,ename,job,mgr FROM scott.emp START WITH ename = 'KING' CONNECT BY PRIOR empno = mgr; LEVEL EMPNO ENAME
2013-07-16 12:26:35
666
原创 insert all 的使用方法
insert all when a1='001' then into a1 when a1='002' then into a2 when a1='003' then into a3 when a1='004' then into a4 when a1='005' then into a5 select * from test;
2013-07-15 15:25:51
1430
原创 rank (),dense_rank (),row_number () 常见的使用和区别
一:语法(用法):rank() over([partition by col1] order by col2) dense_rank() over([partition by col1] order by col2) row_number() over([partition by col1] order by col2) 其中[partition by col1]可省略。二
2013-07-15 15:09:35
429
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人