pepeorcl
asked on
How do I see full definition of a view?
select text from dba_views where view_name in ('....','...');
does not give me all the text.
How can I find the whole text and definition?
Thanks
does not give me all the text.
How can I find the whole text and definition?
Thanks
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SELECT dbms_metadata.get_ddl('VIE W', 'MY_TABLES')
FROM dual;
FROM dual;
BEFORE ISSUING THE COMMAND U SHOULD SET ,SET LONG 10000
set serveroutput on
CREATE OR REPLACE PROCEDURE put_buffer (v_buffer VARCHAR2) IS
cnt number;
buf VARCHAR2(300);
v_length NUMBER;
BEGIN
V_length := length(v_buffer);
IF V_length <= 250 THEN
DBMS_OUTPUT.PUT_LINE(v_buf fer);
ELSE
cnt := 1;
WHILE cnt < V_length LOOP
IF (V_length - cnt +1) > 250 THEN
buf := SUBSTR(v_buffer,cnt,250);
DBMS_OUTPUT.PUT_LINE(buf);
cnt := cnt + 250;
ELSE
buf := SUBSTR(v_buffer,cnt,V_leng th-cnt+1);
DBMS_OUTPUT.PUT_LINE(buf);
cnt := V_length;
END IF;
END LOOP;
END IF;
END put_buffer;
/
CREATE OR REPLACE PROCEDURE ddl(schema varchar2, name varchar2, type varchar2) IS
v_t VARCHAR2(1500);
v_len NUMBER;
v_buf VARCHAR2(250);
begin
DBMS_OUTPUT.ENABLE(1000000 );
SELECT dbms_metadata.get_ddl(UPPE R(type), UPPER(name), UPPER(schema)) INTO v_t from dual;
v_buf :='';
v_len := length(v_t);
for i in 1..v_len loop
v_buf := v_buf || SUBSTR(v_t, i,1);
if (i mod 250) = 0 then
DBMS_OUTPUT.PUT_LINE(v_buf );
v_buf :='';
end if;
end loop;
v_buf := v_buf ||';';
DBMS_OUTPUT.PUT_LINE(v_buf );
end ddl;
/
execute ddl('schema', 'name', 'VIEW');
CREATE OR REPLACE PROCEDURE put_buffer (v_buffer VARCHAR2) IS
cnt number;
buf VARCHAR2(300);
v_length NUMBER;
BEGIN
V_length := length(v_buffer);
IF V_length <= 250 THEN
DBMS_OUTPUT.PUT_LINE(v_buf
ELSE
cnt := 1;
WHILE cnt < V_length LOOP
IF (V_length - cnt +1) > 250 THEN
buf := SUBSTR(v_buffer,cnt,250);
DBMS_OUTPUT.PUT_LINE(buf);
cnt := cnt + 250;
ELSE
buf := SUBSTR(v_buffer,cnt,V_leng
DBMS_OUTPUT.PUT_LINE(buf);
cnt := V_length;
END IF;
END LOOP;
END IF;
END put_buffer;
/
CREATE OR REPLACE PROCEDURE ddl(schema varchar2, name varchar2, type varchar2) IS
v_t VARCHAR2(1500);
v_len NUMBER;
v_buf VARCHAR2(250);
begin
DBMS_OUTPUT.ENABLE(1000000
SELECT dbms_metadata.get_ddl(UPPE
v_buf :='';
v_len := length(v_t);
for i in 1..v_len loop
v_buf := v_buf || SUBSTR(v_t, i,1);
if (i mod 250) = 0 then
DBMS_OUTPUT.PUT_LINE(v_buf
v_buf :='';
end if;
end loop;
v_buf := v_buf ||';';
DBMS_OUTPUT.PUT_LINE(v_buf
end ddl;
/
execute ddl('schema', 'name', 'VIEW');
"DESCRIBE viewname;" gives the full definition. Did you need to recreate the DDL statement instead?
I think ths may work for you
SQL> set long 10000
SQL> select TEXT
FROM DBA_VIEWS
where OWNER = '<owner_name>' 4 and VIEW_NAME = '<view_name>' ;
Here is a link in whch it was explained in a detailed manner:
http://technopark02.blogspot.com/2007/05/oracle-how-to-get-tableview-definition.html
Thanks,
vkg_26.
Open in new window