PL/SQL: Get All Table Column Names

You can use the following PL/SQL code to query all column names of a table:

DECLARE
  v_column_name VARCHAR2(100);
BEGIN
  FOR c IN (SELECT column_name
              FROM all_tab_columns
             WHERE table_name = 'YOUR_TABLE_NAME')
  LOOP
    v_column_name := c.column_name;
    DBMS_OUTPUT.PUT_LINE(v_column_name);
  END LOOP;
END;

In the code above, replace YOUR_TABLE_NAME with the name of the table you want to query. Then, use the all_tab_columns view to retrieve all column names of the table and use DBMS_OUTPUT.PUT_LINE to output the column names. You can execute this code in a PL/SQL development tool to view all column names of the table.

bannerAds