如何在表的所有列及其具有foriegn密钥关系的子表中搜索匹配的字符串并返回结果。
请有人,给我oracle查询。
此致
答案 0 :(得分:0)
试试这个:
SELECT 'select * from ' || table_name || ' where ' || clause
FROM (SELECT DISTINCT REPLACE(stragg(column_name)
over(PARTITION BY table_name ORDER BY table_name), ',',
' = ''__your_string__'' OR ') || ' = __your_string__' clause,
table_name
FROM user_tab_columns
WHERE table_name IN
(SELECT table_name
FROM all_constraints
WHERE constraint_type = 'R'
AND r_constraint_name IN (SELECT constraint_name
FROM all_constraints
WHERE constraint_type IN ('P', 'U')
AND table_name = '__yout_table__')));
此外,您必须将其包装在PLSQL中或以某种方式循环以执行记录集的每一行。