search entire oracle database for part of string

前端 未结 2 990
孤城傲影
孤城傲影 2021-01-27 12:07

I\'m trying to find a specific string in an entire Oracle database.

I\'ve followed the example in another topic on here (Search All Fields In All Tables For A Specific

相关标签:
2条回答
  • 2021-01-27 12:23

    You can concatenate the bind variable with the wildcard % characters:

    EXECUTE IMMEDIATE
      'SELECT COUNT(*) FROM ' || t.owner || '.' || t.table_name ||
      ' WHERE '||t.column_name||' LIKE ''%'' || :1 || ''%'''
      INTO match_count
      USING 'ALERT';
    

    Note that the single quotes have to be escaped by doubling them up.

    0 讨论(0)
  • 2021-01-27 12:35

    Change it to

    EXECUTE IMMEDIATE
      'SELECT COUNT(*) FROM ' || t.owner || '.' || t.table_name ||
      ' WHERE '||t.column_name||' like :1'
      INTO match_count
      USING '%ALERT%';
    
    0 讨论(0)
提交回复
热议问题