SQL exclude a column using SELECT * [except columnA] FROM tableA?

后端 未结 30 2546
花落未央
花落未央 2020-11-21 23:15

We all know that to select all columns from a table, we can use

SELECT * FROM tableA

Is there a way to exclude column(s) from a table witho

30条回答
  •  心在旅途
    2020-11-22 00:06

    If we are talking of Procedures, it works with this trick to generate a new query and EXECUTE IMMEDIATE it:

    SELECT LISTAGG((column_name), ', ') WITHIN GROUP (ORDER BY column_id)
    INTO var_list_of_columns
    FROM ALL_TAB_COLUMNS
    WHERE table_name = 'PUT_HERE_YOUR_TABLE'
    AND column_name NOT IN ('dont_want_this_column','neither_this_one','etc_column');
    

提交回复
热议问题