Skip to content
April 10, 2012 / doganay

CARDINALITY OF A COLUMN

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Hi,

You can use this sql script to determine the cardinality of a specific column of a table:


undefine OWNER
undefine TABLE_NAME
undefine COL_NAME
accept OWNER prompt "OWNER.............: "
accept TABLE_NAME prompt "TABLE NAME........: "
accept COL_NAME prompt "COLUMN NAME.......: "

select round(
(select count(distinct(&&COL_NAME)) from &&OWNER..&&TABLE_NAME)/
(select count(*) from &&OWNER..&&TABLE_NAME)
,12) CARDINALITY
from dual;

undefine OWNER
undefine TABLE_NAME
undefine COLUMN_NAME

try and pray 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: