To create a script from a view, I tried to use this command:
SELECT 'CREATE OR REPLACE '||view_name||' AS '||text||';' FROM user_views WHERE view_name = 'MY_VIEWNAME';
But I'm getting error "ORA-00932: inconsistent datatypes: expected NUMBER got LONG" because the "TEXT" COLUMN datatype OF USER_VIEWS in data dictionary is long. Any solutions?
Query from DBA_SOURCE instead. The TEXT column of DBA_SOURCE is a VARCHAR2(4000) datatype. There may be multiple rows for your view in this DBA_ view so order by the LINE column as well. Alternatively for Oracle 9i, use the DBMS_METADATA.GET_DDL stored procedure to get the information for you.
Dig Deeper on Oracle database design and architecture
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.