Quickly query whether all fields of the table contain specific data filtering based on the table name

Currently, we need to clean up all the fields in a table and check whether there is dirty data containing @DEl@ characters. If there are relatively few fields, we can directly query based on the fields. However, if there are dozens of fields, checking one by one will be very slow.

The current method used is:
1: Get all the fields of the current table based on the table name
2: Build a filter through field splicing Condition
3: Use this unified field to query

Take oracle as an example:

 SELECT ' ' || LISTAGG(COLUMN_NAME, ' ||  ') WITHIN GROUP(ORDER BY COLUMN_ID) AS full_select_sql
   FROM ALL_TAB_COLUMNS
  WHERE TABLE_NAME = '表名称'
  GROUP BY TABLE_NAME;

Insert image description here

SELECT
	t.ROWID,
	t.* 
FROM
	my_table_name  t 
WHERE
	( COLOR || CART_TYPE || CART_LENGTH ||  其他字段...) LIKE '%@DEL@%';

In this way, it is relatively faster to match data and locate problem fields.

Guess you like

Origin blog.csdn.net/Octopus21/article/details/133279964
Recommended