SQL Language (MOSC)

MOSC Banner

updating all columns with default value of schema tables

edited Feb 18, 2010 5:21AM in SQL Language (MOSC) 4 commentsAnswered
 
Hi,

We have a the following requirement

Update the values of application schema tables so that any table with column_type "CHAR" is updated with a default value of " "
and any table with a column_type "NUMERIC" is updated with "0"

This should only happen for columns which already do not have a default value 

we were thinking of writing a simple script like following to accomplish this 
 

Select ‘alter table ‘||table_name||’ modify (‘||column_name||’ default 0)’)
From USER_TAB_COLUMNS
Where data_type = ‘NUMERIC’;


but the problem is that it will run this for ALL the numeric columns where it already has a DEFAULT value or not and we dont need that

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center