Query to search all packages for table and/or column

后端 未结 4 1360
心在旅途
心在旅途 2020-12-01 01:37

Is there a query I can run to search all packages to see if a particular table and/or column is used in the package? There are too many packages to open each one and do a fi

4条回答
  •  不思量自难忘°
    2020-12-01 02:19

    Sometimes the column you are looking for may be part of the name of many other things that you are not interested in.

    For example I was recently looking for a column called "BQR", which also forms part of many other columns such as "BQR_OWNER", "PROP_BQR", etc.

    So I would like to have the checkbox that word processors have to indicate "Whole words only".

    Unfortunately LIKE has no such functionality, but REGEXP_LIKE can help.

    SELECT *
      FROM user_source
     WHERE regexp_like(text, '(\s|\.|,|^)bqr(\s|,|$)');
    

    This is the regular expression to find this column and exclude the other columns with "BQR" as part of the name:

    (\s|\.|,|^)bqr(\s|,|$)
    

    The regular expression matches white-space (\s), or (|) period (.), or (|) comma (,), or (|) start-of-line (^), followed by "bqr", followed by white-space, comma or end-of-line ($).

提交回复
热议问题