我这里需要进行的操作是将所有表中,列名为CREATED_BY,CREATED_DATE,LAST_MODIFIED_BY,LAST_MODIFIED_BY的列更新为null,代码和执行结果如下。
DECLARE sqlS VARCHAR (32760) ;
BEGIN
FOR table_name IN (
SELECT
table_name
FROM
user_tab_columns
WHERE
column_name = 'CREATED_BY'
)
loop
sqlS := (
'UPDATE ' || table_name.TABLE_NAME || ' SET CREATED_BY = NULL, CREATED_DATE = NULL, LAST_MODIFIED_BY = NULL, LAST_MODIFIED_DATE = NULL'
) ;
EXECUTE IMMEDIATE sqlS ;
dbms_output.put_line (sqlS) ;
END loop ;
dbms_output.put_line ('更新结束!') ;
END ;
执行结果如下: