Reputation: 1223
I have a table with thousands of columns, need to merge with the other table with thousands of columns. I need to add pre-fix to avoid conflict, any quick way to change all columns in one table with a pre-fix?
Upvotes: 3
Views: 1865
Reputation: 2415
If you have necessary permissions to update meta-store you can try this query which will update all the column names of your table with a prefix
UPDATE COLUMNS_V2 C JOIN TBLS T
ON C.CD_ID= T.TBL_ID AND
T.TBL_NAME='table_name' SET C.COLUMN_NAME =CONCAT('prefix_',C.COLUMN_NAME) ;
in the above query , replace the following :
'table_name': table name with columns for which you wanted to add prefix for.
'prefix_' : prefix of your choice , example 'tbl_'
Upvotes: 1