Hi Friends!! How to retrive the no.of fields in a table..Can anybody Assist me?Thanks&RegdsRamki

Showing Answers 1 - 15 of 15 Answers

Nishant Goyal

  • Aug 14th, 2006
 

Hello ,

  use this commend.

select count(*) from user_tab_columns where table_name= <table name>

  Was this answer useful?  Yes

Jagan

  • Sep 10th, 2006
 

select count(*) from emp

  Was this answer useful?  Yes

Srinu

  • Oct 9th, 2006
 

select table_name,count(*) from user_tab_columns where table_name='????'
group by table_name

Srinu

  Was this answer useful?  Yes

prasanna

  • Nov 14th, 2006
 

hi

    if u dont mind understand the question properly please

  Was this answer useful?  Yes

Hi all plz understand the question.........
Hi Ramki try this!

SELECT COUNT (COLUMN_NAME) FROM USER_TAB_COLUMNS WHERE TABLE_NAME = 'TABLENAME';

FOR example;

SQL> SELECT COUNT(COLUMN_NAME) FROM USER_TAB_COLUMNS WHERE TABLE_NAME = 'TEST';


COUNT(COLUMN_NAME)
------------------
                 3

SQL> DESC TEST;
 Name                            Null?    Type
 ------------------------------- -------- ----
 ENAME                                    VARCHAR2(20)
 ID                                       VARCHAR2(20)
 SALARY                                   NUMBER

  Was this answer useful?  Yes

DECLARE
CURSOR CUR_TABLES IS
SELECT table_name from user_tables;

V_TABLE NUMBER(5);
v_table_name varchar2(100);
BEGIN

FOR I IN CUR_TABLES
LOOP
SELECT COUNT(1)
INTO V_TABLE
FROM (SELECT table_name from user_tables
where table_name=i.table_name);

IF V_TABLE <= 0 THEN
DBMS_OUTput.PUT_LINE('TABLE NAME' || I.TABLE_NAME);
END IF;
END LOOP;
END;

cheers..!!!!

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions