[20230903]完善hide.sql脚本2.txt

这篇具有很好参考价值的文章主要介绍了[20230903]完善hide.sql脚本2.txt。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

[20230903]完善hide.sql脚本2.txt

--//以前写的用来查询隐含参数的脚本如下:
$ cat hide.sql
col name format a40
col description format a66
col session_value format a22
col default_value format a22
col system_value format a22

select
   a.ksppinm  name,
   a.ksppdesc DESCRIPTION,
   b.ksppstdf DEFAULT_VALUE,
   b.ksppstvl SESSION_VALUE,
   c.ksppstvl SYSTEM_VALUE,
   DECODE (BITAND (a.ksppiflg / 256, 1), 1, 'TRUE', 'FALSE')  ISSES_MODIFIABLE,
   DECODE
       (
          BITAND (a.ksppiflg / 65536, 3)
         ,1, 'IMMEDIATE'
         ,2, 'DEFERRED'
         ,3, 'IMMEDIATE'
         ,'FALSE'
       ) ISSYS_MODIFIABLE
from x$ksppi a, x$ksppcv b, x$ksppsv c
where a.indx = b.indx
 and a.indx = c.indx
 and lower(a.ksppinm) like lower('%&1%')
escape '\'
order by 1;

--//参考链接:http://blog.itpub.net/267265/viewspace-2752521/=>[20210125]完善hide.sql脚本.txt
--//一直存在一个小问题,假如查询如下:

SYS@test> @ hide log_archive_dest_2
NAME                DESCRIPTION                          DEFAULT_VALUE SESSION_VALUE SYSTEM_VALUE ISSES ISSYS_MOD
------------------- ------------------------------------ ------------- ------------- ------------ ----- ---------
log_archive_dest_2  archival destination #2 text string  TRUE                                     TRUE  IMMEDIATE
log_archive_dest_20 archival destination #20 text string TRUE                                     TRUE  IMMEDIATE
log_archive_dest_21 archival destination #21 text string TRUE                                     TRUE  IMMEDIATE
log_archive_dest_22 archival destination #22 text string TRUE                                     TRUE  IMMEDIATE
log_archive_dest_23 archival destination #23 text string TRUE                                     TRUE  IMMEDIATE
log_archive_dest_24 archival destination #24 text string TRUE                                     TRUE  IMMEDIATE
log_archive_dest_25 archival destination #25 text string TRUE                                     TRUE  IMMEDIATE
log_archive_dest_26 archival destination #26 text string TRUE                                     TRUE  IMMEDIATE
log_archive_dest_27 archival destination #27 text string TRUE                                     TRUE  IMMEDIATE
log_archive_dest_28 archival destination #28 text string TRUE                                     TRUE  IMMEDIATE
log_archive_dest_29 archival destination #29 text string TRUE                                     TRUE  IMMEDIATE
11 rows selected.
--//显示一堆自己不需要的查看的log_archive_dest_2X参数,以前遇到这类情况我仅仅粘贴log_archive_dest_2的结果。
--//而且要显示log_archive_dest_3参数,要另外执行@ hide log_archive_dest_3.
--//最近优化项目时才想到使用正则表达式可以很好地规避这些缺点,改写如下:
$ cat hide.sql
col name format a40
col description format a66
col session_value format a22
col default_value format a22
col system_value format a22

select
   a.ksppinm  name,
   a.ksppdesc DESCRIPTION,
   b.ksppstdf DEFAULT_VALUE,
   b.ksppstvl SESSION_VALUE,
   c.ksppstvl SYSTEM_VALUE,
   DECODE (BITAND (a.ksppiflg / 256, 1), 1, 'TRUE', 'FALSE')  ISSES_MODIFIABLE,
   DECODE
       (
          BITAND (a.ksppiflg / 65536, 3)
         ,1, 'IMMEDIATE'
         ,2, 'DEFERRED'
         ,3, 'IMMEDIATE'
         ,'FALSE'
       ) ISSYS_MODIFIABLE
from x$ksppi a, x$ksppcv b, x$ksppsv c
where a.indx = b.indx
 and a.indx = c.indx
-- and lower(a.ksppinm) like lower('%&1%')
--escape '\'
and regexp_like (lower(a.ksppinm) ,lower('&1'))
order by 1;

--//这样就灵活许多,只要知道正则表达式的写法,很容易完成需要的显示结果。比如我需要显示
--//log_archive_dest_2,log_archive_dest_3参数,执行如下:
SYS@test> @ hide log_archive_dest_[23]$
NAME               DESCRIPTION                         DEFAULT_VALUE SESSION_VALUE SYSTEM_VALUE ISSES ISSYS_MOD
------------------ ----------------------------------- ------------- ------------- ------------ ----- ---------
log_archive_dest_2 archival destination #2 text string TRUE                                     TRUE  IMMEDIATE
log_archive_dest_3 archival destination #3 text string TRUE                                     TRUE  IMMEDIATE

--//而且里面_不再像以前的like那样解析为任意字符。以前要显示包含"_ash_"字符串的参数,以前要执行@ hide \_ash\_
--//现在只要知道正则表达式的语法,就可以很容易实现满足自己需要的查询结果。
--//例子:
@ hide _ash_
@ hide ^_ash_
@ hide log_archive_dest_[[:digit:]]
@ hide log_archive_dest_[[:digit:]]{1}$

--//注:输出结果我不再贴出,大家可以自行测试.为了保留原来的执行文件,我把新建立的执行脚本命名hidez.sql.
--//顺便贴上一些正则表达式的解析,摘自man grep文档,许多自己不经常使用,做一个记录.

Character Classes and Bracket Expressions

A  bracket expression is a list of characters enclosed by [ and ].  It matches any single character in that list.  If
the first character of the list is the caret ^ then it matches any character not in the list;it is unspecified whether
it matches an encoding error.  For example, the regular expression [0123456789] matches any single digit.

Within a bracket expression, a range expression consists of two characters separated by a hyphen.  It matches any single
character that sorts between the two characters, inclusive, using the  locale's  collating sequence  and  character
set.   For  example, in the default C locale, [a-d] is equivalent to [abcd].  Many locales sort characters in dictionary
order, and in these locales [a-d] is typically not equivalent to [abcd]; it might be equivalent to [aBbCcDd], for
example.  To obtain the traditional interpretation of bracket expressions, you can use the C locale by setting the
LC_ALL environment variable to the value C.

Finally, certain named classes of characters are predefined within bracket expressions, as follows.  Their names are
self  explanatory,  and  they  are  [:alnum:],  [:alpha:],  [:blank:],  [:cntrl:],  [:digit:], [:graph:],  [:lower:],
[:print:],  [:punct:],  [:space:],  [:upper:], and [:xdigit:].  For example, [[:alnum:]] means the character class of
numbers and letters in the current locale.  In the C locale and ASCII character set encoding, this is the same as
[0-9A-Za-z].  (Note that the brackets in these class names are part of the symbolic names, and must be included in
addition to  the  brackets  delimiting  the  bracket expression.)   Most  meta-characters  lose  their  special  meaning
inside bracket expressions.  To include a literal ] place it first in the list.  Similarly, to include a literal ^ place
it anywhere but first. Finally, to include a literal - place it last.

Anchoring

The caret ^ and the dollar sign $ are meta-characters that respectively match the empty string at the beginning and end
of a line.

The Backslash Character and Special Expressions

The symbols \< and \> respectively match the empty string at the beginning and end of a word.  The symbol \b matches the
empty string at the edge of a word, and \B matches the empty string provided it's  not  at  the edge of a word.  The
symbol \w is a synonym for [_[:alnum:]] and \W is a synonym for [^_[:alnum:]].

Repetition
A regular expression may be followed by one of several repetition operators:
?      The preceding item is optional and matched at most once.
*      The preceding item will be matched zero or more times.
+      The preceding item will be matched one or more times.
{n}    The preceding item is matched exactly n times.
{n,}   The preceding item is matched n or more times.
{,m}   The preceding item is matched at most m times.  This is a GNU extension.
{n,m}  The preceding item is matched at least n times, but not more than m times.

文章来源地址https://www.toymoban.com/news/detail-693946.html

到了这里,关于[20230903]完善hide.sql脚本2.txt的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 【REST2SQL】08 日志重构增加输出到文件log.txt

    【REST2SQL】01RDB关系型数据库REST初设计 【REST2SQL】02 GO连接Oracle数据库 【REST2SQL】03 GO读取JSON文件 【REST2SQL】04 REST2SQL第一版Oracle版实现 【REST2SQL】05 GO 操作 达梦 数据库 【REST2SQL】06 GO 跨包接口重构代码 【REST2SQL】07 GO 操作 Mysql 数据库 原来的日志只输出到控制台,关闭控制台

    2024年02月01日
    浏览(33)
  • 无涯教程-jQuery - hide( speed, callback)方法函数

    hide(speed,[callback])方法使用优美的动画隐藏所有匹配的元素,并在完成后触发可选的回调。 这是此方法使用的所有参数的描述- speed      -  代表三个预定义速度(\\\"slow\\\",\\\"normal\\\"或\\\"fast\\\")之一或运行动画的毫秒数(如1000)的字符串)。 callback -  这是可选参数,表示动画制作完成后要

    2024年02月15日
    浏览(26)
  • 测试之@Sql(自动插入sql脚本,测试后销毁)

    目录 前言 @Sql @SqlConfig @SqlMergeMode @Transactional 案例 参考自: 解决测试时测试数据写入与销毁不方便,使用@Sql自动导入sql脚本语句,结合@Transactional事务回滚实现测试后数据销毁,便捷测试。 @Sql注解可以执行SQL脚本,也可以执行SQL语句。它既可以加上类上面,也可以加在方法

    2023年04月08日
    浏览(17)
  • dbeaver导入sql脚本

       然后按确定就行了  

    2024年02月11日
    浏览(30)
  • [HCTF 2018] Hide and seek(buuctf),Unzip(ctfshow)

     考核完对python软连接还是不熟悉,把这两道题在做一下  登录注册之后发现可以上传文件,随便上传一个 回显说不是zip文件   上传一个zip文件,发现他会自动解析 上传了一个 GIF89a ?php @eval($_POST[\\\'zxc\\\']); ? 应该是python软链接,尝试一下 把/etc/passwd创建一个软连接然后进行压缩

    2024年02月07日
    浏览(34)
  • DBeaver SQL脚本执行配置

    对生产环境数据迁移到测试环境时,单条执行可能时间过长、或者内存装不下。最快的方法是执行SQL脚本。 本地数据库客户端:DBeaver 该客户端是不自带脚本执行客户端的,如下图: mysql官网下载workbench,可以连通客户端执行组件一起下载下来:MySQL :: Download MySQL Workbench 之后

    2024年01月17日
    浏览(28)
  • Kettle(11):SQL脚本组件

    接下来,我们来讲解一个高级用法。在实际开发中,也经常容易使用得到。假设我们有一段SQL脚本,想要用Kettle来执行,此时该使用哪个组件呢? 1 组件介绍 执行SQL脚本组件,可以让Kettle执行一段SQL脚本。我们可以利用它来自动执行某些操作。 2 需求 使用Kettle执行SQL脚本,

    2024年02月15日
    浏览(53)
  • postgresql|数据库|批量执行SQL脚本文件的shell脚本

    对于数据库的维护而言,肯定是有SQL脚本的执行,例如,某个项目需要更新,那么,可能会有很多的SQL脚本需要执行,SQL脚本可能会包含有建表,插入数据,索引建立,约束建立,主外键建立等等内容。 那么,几个SQL脚本可能无所谓,navicat或者psql命令行 简简单单的就导入了

    2024年02月01日
    浏览(48)
  • Excel 数据转化为Sql脚本

    在实际项目开发中,有时会遇到客户让我们把大量Excel数据导入数据库的情况。这时我们就可以通过将Excel数据转化为sql脚本来批量导入数据库。 步骤一:在数据前插入一列单元格,用来拼写sql语句。 \\\"B2\\\"代表B2单元格数据,如果单元格数据为字符串 需用‘’包裹。 步骤二:

    2024年02月16日
    浏览(30)
  • 工作中常用到的一些sql脚本

    – 存储过程查询(存储过程/函数 查询) select * from pg_proc where lower(prosrc) like ‘%%’; – 复制表数据 insert into 表(字段) select 字段 from 表 where 条件; – 查询重复数据 select COUNT(0),字段名 from 表名 where state = ‘E’ GROUP BY 字段名 HAVING COUNT(0) 1; – 表所属库 ALTER TABLE

    2024年04月26日
    浏览(20)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包