Search notes:

Oracle: Using SQL to create a SELECT statement with a table's column names

with par as (
   select
       'idt'                    as alias     ,
       'dba_identifiers'        as table_name,
        user                    as owner
   from
      dual
),
lines as (

   select 'select'                                                                         stmt, 0 order_by from par union all

   select
      '   ' ||
     -- rpad(par.alias || '.' || lower(column_name), 40)||
     --      par.alias || '_' || lower(column_name)     ||
             par.alias || '.' || lower(column_name)     ||
       case when row_number() over (order by column_name) < count(*) over () then ',' end  stmt, 1
   from
      par                  cross join
      dba_tab_columns col
   where
      col.owner      = upper(par.owner     )   and
      col.table_name = upper(par.table_name)                                                                         union all

   select 'from'                                                                               , 2 from dual         union all
   select '   ' || par.owner || '.' || table_name || ' ' || alias || ';'                       , 3 from par
)
select
   stmt
from
   lines
order by
   order_by,
   stmt
;

See also

column

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758199431, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/databases/Oracle/objects/tables/columns/create-select-statement-with-tables-column-names(70): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78