Reputation: 113
I wanna comment all columns of all tables where the column have Foreing key with one especific table.
I know comment one by one, but they are many fields
Upvotes: 1
Views: 3150
Reputation: 113
SELECT
'COMMENT ON COLUMN ' as command1,
SYS.ALL_TAB_COLUMNS.OWNER,
'.' as command2,
SYS.ALL_TAB_COLUMNS.TABLE_NAME,
'.' as command3,
SYS.ALL_TAB_COLUMNS.COLUMN_NAME,
' is ''@Enumeration=boleano' as coment_to_add,
SYS.ALL_COL_COMMENTS.COMMENTS,
''';' as command5
FROM
SYS.ALL_TAB_COLUMNS
INNER JOIN SYS.ALL_COL_COMMENTS ON SYS.ALL_TAB_COLUMNS.COLUMN_NAME = SYS.ALL_COL_COMMENTS.COLUMN_NAME AND SYS.ALL_TAB_COLUMNS.TABLE_NAME = SYS.ALL_COL_COMMENTS.TABLE_NAME AND SYS.ALL_TAB_COLUMNS.OWNER = SYS.ALL_COL_COMMENTS.OWNER
WHERE
SYS.ALL_TAB_COLUMNS.OWNER LIKE '$MY_OWNER'
The result exported to txt file is the script;
Upvotes: 3