I'm very new to SQL developer and am now working with an existing Database. The tables do not have column comments and I've been tasked to add them. I created an excel spreadsheet of the column descriptions and imported as a table. I need to write a query for the table with the comments in a column (lets call it Table_1, comments) and insert those comments into the Column Comments for Table_2. If it helps there is a unique column_id number for each comment so comment for Table_1 should be inserted at comment row on Table_2 where Table_1.column_ID = Table_2.column_ID. Thanks in adavance!
I have tried selecting the column from Table_1 and inserting as Comment on Column in Table_2 and got an error. Also tried reversing the order of these as well. I was able to insert each one individually using: -Comment on Column table_name.column_name is 'this comment'; But it is tedious and I want to enter all of the comments at once using a query.
This is about adding a comment to table's column in data dictionary. To do that, you'll need dynamic SQL. Here's an example.
This is table that contains comments you'd want to apply:
For example,
DEPTtable currently doesn't have any comments:Procedure displays command which is then being executed:
Result: