- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
DECLARE
CURSOR get_col1 IS
SELECT DISTINCT
a.constraint_name,
a.constraint_type,
a.table_name,
a.r_constraint_name,
b.column_name
FROM all_constraints a, all_cons_columns b
WHERE a.table_name = b.table_name
AND a.constraint_type in ('P', 'R')
AND a.constraint_name = b.constraint_name
--AND rownum < 20
ORDER by 1;
CURSOR get_col2 IS
SELECT table_name, column_name
FROM all_cons_columns
WHERE constraint_type = 'R';
BEGIN
dbms_output.ENABLE;
dbms_output.put_line(rpad('Имя ограничения', 30)
||rpad('Тип', 5)
||rpad('Имя столбца', 20)
||rpad('Имя таблицы', 20)
||rpad('Имя таблицы', 20)
||rpad('Имя столбца', 20));
dbms_output.put_line(rpad('-', 115, '-'));
FOR main_col IN get_col1 LOOP
dbms_output.put_line(rpad(to_char(main_col.constraint_name), 30)
||rpad(to_char(main_col.constraint_type), 5)
||rpad(to_char(main_col.column_name), 20)
||rpad(to_char(main_col.table_name), 20));
/*IF (main_col.constraint_type = 'R') THEN
dbms_output.put_line(lpad(rpad('Comment', 11), 37)||': '||main_col.comments);
END IF;*/
FOR sec_col IN get_col2 LOOP
IF (main_col.constraint_type = 'R') THEN
dbms_output.put_line(rpad('Index', 10)
||rpad('Index', 10)': '||ind_col.index_name);
END IF;
END LOOP;
dbms_output.new_line();
END LOOP;
END;
/
guest 09.12.2011 13:09 # 0
guest 13.12.2011 11:40 # 0