Foreign Key’e Sahip Kolonların Farklı Data Uzunlukta Olanları Nasıl Bulunur?

Oracle veritabanında oluşturulmuş foreign keylerin bulunduğu kolonların farklı data uzunluğuna sahip olanlarını aşağıdaki sql ile bulabilirsiniz.

SELECT acol.owner,
acol.table_name,
acol.column_name,
acol.data_type,
acol.data_length,
acol.data_precision,
bcol.owner,
bcol.table_name,
bcol.column_name,
bcol.data_type,
bcol.data_length,
bcol.data_precision
FROM dba_tab_columns acol, dba_tab_columns bcol
WHERE (acol.owner,
acol.table_name,
acol.column_name,
bcol.owner,
bcol.table_name,
bcol.column_name) IN
(SELECT b.owner b_owner,
b.table_name b_tblname,
b.column_name b_column,
c.owner c_owner,
c.table_name c_tblname,
c.column_name c_column
FROM dba_cons_columns b,
dba_cons_columns c,
dba_constraints a
WHERE b.constraint_name = a.constraint_name
AND a.owner = b.owner
AND b.position = c.position
AND c.constraint_name = a.r_constraint_name
AND c.owner = a.r_owner
AND a.constraint_type = 'R') and (acol.data_length <> acol.data_length or acol.data_precision <> bcol.data_precision );

Leave a Reply

Your email address will not be published. Required fields are marked *