que performance

Upload: zipzapdhoom

Post on 13-Feb-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/23/2019 Que performance

    1/2

    SELECT cust_no, COUNT(*) AS "Count of Policy" FROM POLICY_ENTITY GROUP BY cust_no ;SELECT cust_no, COUNT(*) AS "Count of Policy" FROM customer GROUP BY cust_no;select * from PROD_LINE_DISC;select DISTINCT prod_id from POLICY_ENTITY;select * from POLICY_ENTITY;select * from customer;select count (DISTINCT cust_no ) from customer;select count (*) from (select POLICY_ENTITY.policy_no ,POLICY_ENTITY.prod_id , customer.cust_no from customer INNER JOIN POLICY_ENTITY ON POLICY_ENTITY.cust_no= customer.cust_no);select count (*) from (select name.surname ,name.id_no , customer.cust_no from name INNER JOIN customer ON name.id_no = customer.cust_no);select name.surname ,name.id_no , customer.cust_no from name INNER JOIN customerON name.id_no = customer.cust_no;SELECT * FROM USER_CONSTRAINTS WHERE TABLE_NAME = 'NAME';SELECT * FROM USER_CONSTRAINTS WHERE TABLE_NAME = 'CUSTOMER';SELECT * FROM ALL_CONS_COLUMNS WHERE TABLE_NAME = 'NAME';select * from name where EFFECTIVE_DATE is not null;select count (distinct OCCUPATION) from customer;select * from customer where birth_date is null;SELECT * FROM USER_CONSTRAINTS WHERE TABLE_NAME = 'NAME';SELECT * FROM ALL_CONS_COLUMNS WHERE TABLE_NAME = 'NAME';select count (NO_MARKETING_IND) from customer;

    select count (VIP_STATUS) from customer;select count (DISTINCT potential) from customer;SELECT * FROM ALL_CONS_COLUMNS WHERE TABLE_NAME = 'CUSTOMER';SELECT table_name, column_name, data_type, data_length FROM USER_TAB_COLUMNS WHERE table_name = 'CUSTOMER_AUDIT';SELECT forename ,COUNT(*) count FROM name GROUP BY forename Having COUNT(*) > 100;SELECT segment_name,segment_type,bytes/1024/1024/1024 gb FROM dba_segmentsWHERE segment_type='TABLE' AND segment_name in('CUSTOMER','NAME','POLICY_ENTITY');SELECT segment_name table_name, sum(bytes)/(1024*1024*1024) table_size_in_gb FROM user_extentsWHERE segment_type='TABLE' AND segment_name in ('CUSTOMER','NAME','POLICY_ENTITY

    ','POLICY') GROUP BY segment_name;select * from name where surname is not null and forename is null;select count (*) from customer where birth_date is null;select count (*) from (select cust_no from customer minus select id_no from name);select count (*) from (select id_no from name minus select cust_no from customer);select * from name where id_no in (select id_no from name minus select cust_nofrom customer);

    Summary

    select * from POLICY_ENTITY;

    select prod_id,current_policy_status,count(*) from policy_entity group by prod_id,current_policy_status order by prod_id,current_policy_status;select prod_id,count(*) from policy_entity group by prod_id order by prod_id;select current_policy_status,count(*) from policy_entity group by current_policy

    _status order by current_policy_status;select prod_id,count(DISTINCT cust_no) from policy_entity group by prod_id order by prod_id;

    To see the duplicate records, follow the example below:

  • 7/23/2019 Que performance

    2/2

    SELECT * FROM TABLE_B WHERE (COLUMN_A||COLUMN_B) IN (SELECT COLUMN_A||COLUMN_B FROM TABLE_A);SELECT COUNT(*), COLUMN_A, COLUMN_B FROM TABLE_B GROUP BY COLUMN_A, COLUMN_B HAVING COUNT(*)>1;select column_name, count(column_name) from table group by column_name having count (column_name) > 1;SELECT * FROM TABLE A WHERE EXISTS (SELECT 1 FROM TABLE WHERE COLUMN_NAME = A.COLUMN_NAME AND ROWID < A.ROWID)