sql - How to put default values for every column in table? -


this syntax doesn't work:

select  nvl(student.*,0) student ; 

how can apply nvl() function every column in student table?

we can't that. need type out columns , individual nvl() functions. know seems lot of effort consider happen if of columns date or other "exotic" datatype.

if have lot of columns , want save effort generate clauses data dictionary:

 select 'nvl('|| column_name || ', 0)'   user_tab_columns  table_name = 'student'  order column_id; 

cut'n'paste result set editor.

once start on route it's easy more sophisticated:

 select case when column_id > 1 ',' end ||        'nvl('|| column_name || ',' ||        case when data_type = 'date' 'sysdate'             when  data_type = 'varchar2' '''def'''              else '0' end ||        ')'   user_tab_columns  table_name = 'student'  order column_id; 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -