We help IT Professionals succeed at work.
Get Started

ALL_TAB_COLUMNS

GouthamAnand
GouthamAnand asked
on
2,522 Views
Last Modified: 2014-05-02
Hi,

In the oracle ALL_TAB_COLUMNS table, there is a column data_default. I am selecting this column where DEFAULT_LENGTH is not null.

But am not able to get the value as the DATA_DEFAULT is LONG data type.

Can you please let me know how can I view the values with a select statement in sqlplus?

CREATE TABLE ABC (A VARCHAR2(10) DEFAULT  'N');

 select data_default from all_tab_columns a where table_name='ABC' and  DEFAULT_LENGTH is not null.

Actually am trying to generate a alter table command.
I create a XYZ table as below

 create table xyz as select * from abc where 1=0;

I need to copy all the default values from ABC to XYZ.
Like this  I need to do for many tables and many columns.
 
For this am trying to execute the below statement.

select 'alter table XYZ modify (' || COLUMN_NAME ||  ' DEFAULT '||  data_default || ' );'
 from ALL_TAB_COLUMNS where TABLE_NAME = 'ABC' and  DEFAULT_LENGTH is not null;

Can you please help?

Thanks,
Comment
Watch Question
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 2 Answers and 14 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE