-1
需要關於PL/SQL代碼的幫助...我需要查看有關用戶希望檢查的模式中每個表的信息,但是在我的結果視圖中,表也會出現,我不需要它們... 我只需要在例如列表的表和字段:表1第1列,表1第2列等 這裏是代碼:使用plsql獲取表信息
CREATE OR replace PROCEDURE table_info_proc(p_schema_name IN VARCHAR2)
IS
TYPE all_tab_columns_type
IS
TABLE OF all_tab_columns%ROWTYPE INDEX BY PLS_INTEGER;
v_all_tab ALL_TAB_COLUMNS_TYPE;
l_row PLS_INTEGER;
v_schema VARCHAR2(50);
v_table_count NUMBER(5);
BEGIN
SELECT DISTINCT(owner)
INTO v_schema
FROM all_objects
WHERE owner = p_schema_name;
dbms_output.Put_line ('SCHEMA NAME: '
|| v_schema);
SELECT * bulk collect
INTO v_all_tab
FROM all_tab_columns
WHERE owner = p_schema_name;
l_row := v_all_tab.first;
WHILE (l_row IS NOT NULL)
LOOP
dbms_output.Put_line ('table: '
|| V_all_tab(l_row).table_name
|| ' column: '
|| V_all_tab(l_row).column_name);
l_row := v_all_tab.NEXT(l_row);
END LOOP;
SELECT count(*)
INTO v_table_count
FROM all_objects
WHERE object_type = 'TABLE'
AND owner = p_schema_name;
dbms_output.Put_line ('NUMBER OF TABLES IN SCHEMA: '
|| v_table_count);
EXCEPTION
WHEN no_data_found THEN
dbms_output.Put_line ('There is no schema named '
|| p_schema_name);
END table_info_proc;
/
是的,但我需要在PLSQL中完成,我無法弄清楚它... – 2014-11-24 09:03:37
好的,請參閱我的編輯。 – 2014-11-24 09:08:32
thx,但仍然不好,它列出視圖以及...我粘貼的解決方案獲得相同的結果... – 2014-11-24 09:15:57