Atomic Habits

오라클 테이블 컬럼 개수 구하기 본문

IT/SQL

오라클 테이블 컬럼 개수 구하기

체계성 2022. 1. 7. 22:27

 

/* 컬럼 총size */

SELECT SUM(data_length)
FROM USER_TAB_COLUMNS
WHERE TABLE_NAME = '테이블명'

 

/* 컬럼 컬럼 갯수 */

SELECT COUNT(*)
FROM USER_TAB_COLUMNS
WHERE TABLE_NAME = upper('대문자 테이블명');

 

select * from user_tab_columns;

 

select table_name, count(*) 
from user_tab_columns 
where table_name in (upper('cc'), upper('t1'))
group by table_name;

 

 

 

/* 참고 */    table_name, count(column_name)  이런 식으로 count도 가능?

select owner, table_name, count(column_name)
from dba_tab_cols
where owner in (select username from dba_users where account_status='OPEN')
group by owner, table_name
order by 1
Comments