Export view ddl script
Has anyone here written or come across a script I can run in sql plus (or otherwise) that will export the ddl for all views in a schema?
SQL Developer allows you to copy a views ddl to a file or clipboard but only one at a time. I would like to be able to do this in bulk somehow.
Thanks.
Ok. Got it. Here is the sample --
satyaki>select DBMS_METADATA.GET_DDL('VIEW',view_name,'SCOTT') res
2 from user_views;
CREATE OR REPLACE FORCE VIEW "SCOTT"."VIEW_NAME" ("DEPARTMENT", "COUNT") AS
SELECT deptno Department, COUNT(*) COUNT
FROM EMP
GROUP BY deptno
HAVING COUNT(*) > 4
CREATE OR REPLACE FORCE VIEW "SCOTT"."TESTVIEW" ("DEPARTMENT", "COUNT") AS
SELECT deptno Department, count(*) COUNT
FROM emp
group by deptno
having count(*) > 4
CREATE OR REPLACE FORCE VIEW "SCOTT"."TESTVIEW1" ("DEPARTMENT", "COUNT") AS
SELECT deptno Department, count(*) COUNT
FROM emp
group by deptno
having count(*) = 1
CREATE OR REPLACE FORCE VIEW "SCOTT"."TESTV1" ("EMPNO", "ENAME", "JOB", "MGR",
"HIREDATE", "SAL", "COMM", "DEPTNO", "CODE") AS
select "EMPNO","ENAME","JOB","MGR","HIREDATE","SAL","COMM","DEPTNO","CODE" fro
m emp
CREATE OR REPLACE FORCE VIEW "SCOTT"."TEST_EMP_V" ("EMPNO", "ENAME", "DEPTNO")
AS
select empno,ename,deptno
from emp
CREATE OR REPLACE FORCE VIEW "SCOTT"."EMP_SAT_DET" ("EMPNO", "MGR", "LOC", "PH
ONE") AS
select empno,mgr,loc,phone
from emp,dept
where emp.deptno = dept.deptno
CREATE OR REPLACE FORCE VIEW "SCOTT"."BDET" ("A", "B", "C",
PRIMARY KEY ("A") DISABLE) AS
select "A","B","C" from d1
CREATE OR REPLACE FORCE VIEW "SCOTT"."V_EMP" ("EMPNO", "ENAME", "JOB", "MGR",
"HIREDATE", "SAL", "COMM", "DEPTNO", "CODE", "PHONE") AS
WITH e AS (
SELECT *
FROM emp)
SELECT "EMPNO","ENAME","JOB","MGR","HIREDATE","SAL","COMM","DEPTNO","CODE
","PHONE"
FROM e
CREATE OR REPLACE FORCE VIEW "SCOTT"."V1" ("SOME_ID", "SOME_VALUE", "GID") AS
select "SOME_ID","SOME_VALUE","GID"
from (
select some_id, some_value,
grouping_id (some_id, some_value) gid
from t1p
group by rollup (some_id, some_value)
union all
select some_id, some_value,
grouping_id (some_id, some_value) gid
from t2p
group by rollup (some_id, some_value))
CREATE OR REPLACE FORCE VIEW "SCOTT"."VV1" ("EMPNO", "ENAME", "WORK_DAYS") AS
select empno,ename,sysdate-hiredate work_days
from emp
CREATE OR REPLACE FORCE VIEW "SCOTT"."EMPV" ("EMPNO", "ENAME", "JOB", "MGR", "
HIREDATE", "SAL", "COMM", "DEPTNO", "CODE", "PHONE") AS
select "EMPNO","ENAME","JOB","MGR","HIREDATE","SAL","COMM","DEPTNO","CODE","PH
ONE" from emp
CREATE OR REPLACE FORCE VIEW "SCOTT"."UPD_VIEW" ("PERSON_ID", "FIRST_NAME", "L
AST_NAME") AS
SELECT "PERSON_ID","FIRST_NAME","LAST_NAME" FROM demo_tab
12 rows selected.Regards.
Satyaki De.
Similar Messages
-
Error when Exporting DDL script for whole schema
When I right click connection, Select "Export" then "DDL Script", the following error occur (Exception Stack Trace)
java.lang.ClassNotFoundException: oracle.dbtools.raptor.dialogs.actions.UserDDLExport
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at oracle.ideimpl.IdeClassLoader.loadClass(IdeClassLoader.java:140)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at oracle.dbtools.raptor.dialogs.BasicObjectModifier.launch(BasicObjectModifier.java:142)
at oracle.dbtools.raptor.dialogs.BasicObjectModifier.handleEvent(BasicObjectModifier.java:210)
at oracle.dbtools.raptor.dialogs.actions.XMLBasedObjectAction$DefaultController.handleEvent(XMLBasedObjectAction.java:265)
at oracle.ide.controller.IdeAction.performAction(IdeAction.java:530)
at oracle.ide.controller.IdeAction$1.run(IdeAction.java:785)
at oracle.ide.controller.IdeAction.actionPerformedImpl(IdeAction.java:804)
at oracle.ide.controller.IdeAction.actionPerformed(IdeAction.java:499)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.AbstractButton.doClick(AbstractButton.java:302)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1000)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1041)
at java.awt.Component.processMouseEvent(Component.java:5488)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
at java.awt.Component.processEvent(Component.java:5253)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3955)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
at java.awt.Container.dispatchEventImpl(Container.java:2010)
at java.awt.Window.dispatchEventImpl(Window.java:1774)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)This is actually in our release notes as not implemented yet.
The following capabilities are currently planned to be added by the production release:
Tools > Export - Will be a DDL generator.
I will mention in the release notes when this function is operational. The menu item is just there now as a placeholder.
-- Sharon -
How to view the DDL script prior to object deployment in OWB 10g R2?
How to view the DDL script prior to object deployment in OWB 10g R2?
Here is what I' looking for: in 10gR2, let's say I've built dimension X, but it's not deployed yet. I've selected one of the deployment options, let's say: "Deploy to Catalog only". Now, I'd like to see a DDL script that will be executed at the deployment time. Where can I find this script? What screen? What menu?
Thanks,
vrViewing the Scripts
After you have generated scripts for your target objects, you can open the scripts and
view the code. Warehouse Builder generates the following types of scripts:
■ DDL scripts: Creates or drops database objects.
■ SQL*Loader control files: Extracts and transports data from file sources.
■ ABAP scripts: Extracts and loads data from SAP systems.
To view the generated scripts:
1. From the Generation Results window, select an object in the navigation tree on the
left of the Generation Results dialog.
2. Select the Scripts tab on the right of this dialog.
The Scripts tab contains a list of the generated scripts for the object you selected.
3. Select a specific script and click the View Code button.
Regards,
Marcos -
EXP-00024: Export views not installed, please notify your DBA - Please help
Sir,
I am trying to export from a client machine.
exp system/manager@dbcon full=y file=db.dmp log=exp.logBut I am getting error,
Connected to: Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production
Export done in US7ASCII character set and AL16UTF16 NCHAR character set
About to export the entire database ...
. exporting tablespace definitions
. exporting profiles
. exporting user definitions
. exporting roles
. exporting resource costs
. exporting rollback segment definitions
. exporting database links
. exporting sequence numbers
. exporting directory aliases
. exporting context namespaces
. exporting foreign function library names
. exporting object type definitions
EXP-00008: ORACLE error 942 encountered
ORA-00942: table or view does not exist
EXP-00024: Export views not installed, please notify your DBA
EXP-00000: Export terminated unsuccessfully
This happens while exporting from a remote client machine. When I export from The machine where database resides, there is no problem at all. Why tis happens?
regards,
MathewMay we know the database version of your exported and imported database ? I believe that , you trying to import into lower version of database. If yes, then loging as a sys and run the script $ORACLE_HOME/rdbms/admin/catexp.sql .
hare krishna
Alok -
SAP HANA: IMPORT/EXPORT Views
We can Import/export tables using hdbsql CLI.
But Is there any way by which we can export/import Views(attribute,analytic,calculation) using hdbsql CLI.
I raised above question some days back
SAP HANA: IMPORT/EXPORT Views | SCN
Also while checking on internet I found another link for the same issue:
http://scn.sap.com/thread/2141404
And from experts answers, I came to conclusion that Import/Export Views(Attribute/Analytic/Calculation views)in SAP HANA is not possible through hdbsql CLI/ SQL commands.Now Is there a way where I can confirm this from SAP HANA program management guys?Lars,
Thanks for the explanation.
What I am trying to achieve is to create an automate script which should export all tables and views for a schema and again import tables and views in a different schema.
table part is done, But stuck in view part.
I tried the below command and was able to export the calculation view which I created in Content and exists as
_SYS_BIC-->Package(same name as schema where all the tables are stored) --> View Name.
Command used was:
EXPORT "<Schema_Name>"."<Package_Name>/<View_Name>" INTO '<path>'
Now I have 2 ques :
1) I am not sure how to import this exported view. I tried below command but it failed:
IMPORT "<Schema_Name>"."<Package_Name>/<View_Name>" FROM '<path>'
2) Not sure how to export and import all the views.
I did IMPORT SCAN of the path as well and found below entries for the exported view in the mentioned path:
SCHEMA_NAME, OBJECT_NAME, OBJECT_TYPE, EXISTS
"_SYS_BIC", "<Packagename>/CalculationViewName>", "VIEW", 1
"_SYS_BIC", "<Packagename>/AnalyticViewName>", "VIEW", 1
"_SYS_BIC", "<Packagename>/CalculationViewName>/olap", "VIEW", 1
"_SYS_BIC", "vwTile1ALLData", "VIEW", 1
Any Inputs would definitely help. Thanks. -
How to view full script in sql*plus
Hi,
i am having a user who want to view the script for trigger by querying user_triggers in SQL*PLUS. i just remembered that there is some DBMS_ package for doing this. can anyone please provide that package name.
thanks in advanceWere you thinking of DBMS_METADATA?
Have a look at this: http://blogs.ittoolbox.com/database/solutions/archives/ddl-generationoracles-answer-to-save-you-time-and-money-7590 -
Is there procedure/package/command in Oracle which will generate DDL script for existing objects, like
CREATE TABLE table_name
(col1 NUMBER(15,0) NOT NULL,
col3 VARCHAR2(12))
PCTFREE 10
PCTUSED 40
INITRANS 1
MAXTRANS 255
ALTER TABLE table_name
ADD PRIMARY KEY (col1)
USING INDEX
PCTFREE 10
INITRANS 2
MAXTRANS 255
CREATE UNIQUE INDEX idx_c001 ON table_name
col1 ASC
PCTFREE 10
INITRANS 2
MAXTRANS 255
ThanksThis Q&A covers using export/import to get DDL:
http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:439019911488
This covers the exp/imp method but also includes an example from someone that provides cleaner DDL:
http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:1464804639878 -
EXP-00037: Export views not compatible with database version
kindly help with this error. We have already run catexp.sql but still that is not helping, we are still getting the same error.
we are exporting 8i db.
Export: Release 8.1.7.0.0 - Production on Thu Feb 21 14:34:25 2008
(c) Copyright 2000 Oracle Corporation. All rights reserved.
Connected to: Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production
With the Partitioning option
JServer Release 8.1.7.0.0 - Production
EXP-00037: Export views not compatible with database version
EXP-00000: Export terminated unsuccessfullyDoes this apply to you?
Error: EXP 37
Text: Export views not compatible with database version
Cause: The Export utility is at a higher version than the database version
and is thereby incompatible.
Action: Use the same version of Export utility as the database. -
How to generate the DDL script of all the schema objects.
Hi All,
I just wanted to make centralized repository for Oracle database and to create a base version, I need to create the DDL scripts of all the database objects so that i can check in the same ddl scripts (sql) files in to my central repository.
I need do this schedule job which will generate the ddl scripts once in a month(This should be automated process)
Please help me out about this.
Oracle version - 9i
Thanks in advance.
Thanks,
Santosh
Edited by: Santosh_Oracle on Feb 23, 2011 10:26 PMIt is definitely possible to revise the script.
Look at it, you already have 80 percent of it for free, and you didn't even need to Google.
Just ask a FAQ in a forum loaded with FAQs!
And Toad can save everything to one script per object.
Sybrand Bakker
Senior Oracle DBA -
Changes in the value of the Arc property "Include in DDL Script" is not being saved.
I have arcs in my design that I want that the automatic DDL code not being generated because the FK are compound and the code generated for the validation of the arc in these more complex cases is not correct, so I created an explicit constraint on the table for this validation.
But the problem is that the Arc property "Include into DDL Script" is not being saved into the design.
If I unchecked the option for the arc and generate or preview the DDL the arc code is not generated.
But when I save the project, close and reopen the arcs have this option enabled again.
I've been checking the xml files for the arcs and this property is not being included, then by default generates always.
Thanks!This problem is fixed in Data Modeler version 4.0 EA3 which is now available to download.
David -
Problem downloading the ddl script
Hi all,
I am trying to upload a DDL script to execute it on my new apex application.
It doesn't work, I get an error, I realised that I have to copy and past the code of the creation of a table one by one.
Do you have any idea how to fix that ? to execute the ddl script at once ?
I cannot execute hundreds of queries one by one
Thank you, it is urgentMoun wrote:
Hi all,
I am trying to upload a DDL script to execute it on my new apex application.
It doesn't work, I get an error, I realised that I have to copy and past the code of the creation of a table one by one.
Do you have any idea how to fix that ? to execute the ddl script at once ?
I cannot execute hundreds of queries one by one
Thank you, it is urgentYour problems are no more or less "urgent" than any others on this forum, and the volunteers here are free to use their time as they see fit. Making claims of "urgency" is the best way to get your question ignored.
However in this case the problem is quite simple: you have not bothered to consult the documentation. Use the SQL Workshop SQL Scripts page. -
Using Attribute views in Script based Calculation views
I am trying to create a view for analysis on a fact table which has measure name as a dimension as opposed to having multiple measures. Here is an example of what the data looks like.
#Customer, Product, Measure, Data
Customer1, Product1, ASP, 4.2
Customer1, Product1, Units, 100
Customer2, Product2, ASP, 4.4
Customer2, Product2, Units, 200
... and so on and so forth.
I had build Attribute views with hierarchies for both customer and product dimensions and build analytic views. However now I have the need to flatten the Measures dimension and have the resulting Fact view look like:
#Customer, Product, ASP, Units
Customer1, Product1, 4.2, 100
Customer2, Product2, 4.4, 200
... and so on and so forth.
Now I want to build analytic views on this flattened view of my Fact table.
I was able to create a calculation view using Script mode, on the fact table and write a SQL to flatten the Measure dimension. But I am not able to now join this calculation view with the attribute views. Is there a way to leverage the existing Attribute views and their hierarchies in this case?
The only way I can see for now is to use manual SQL to build out the entire view, including joining the attribute views and re-build the hierarchies in the definition of the calculation view. This essentially wastes work I have already done in the attribute views and forces me to build the entire thing using SQL.
Is there a better approach?It's extremely annoying that the FLD() command isn't yet availlable in NW, unless it's coming with 7.5 or has been included in one of the more recent support packs.
As a an alternative you may be able to use the following MDX routine:
Returns the value of a property of the current member of a dimension
*function PRO(%DIMENSIONNAME%,%PROPERTYNAME%)
%DIMENSIONNAME%.Properties("%PROPERTYNAME%")
*endfunction
Unfortunately I've never been able to use this with a When statement, so you may have to ask an ABAP resource to develop a BADI to achieve your required results. -
Dear All
I have a user account in a database, under this account, i create a lot of view(Over 100) which is point to another database server table, and i want to export all of them and then import to another database. How i can do that?? I have check the export command, but how can i use this command to export view only?? how can i use to import?? Please help me.
Thanks for your help.
TonyYou cannot export views only. You can do a user export, and a user import on the other database.
-
How to get DDL Script in Oracle 11g
How can i get DDL Script in Oracle 11g database.
I am using windows as OS
Can anyone help me to get solution.
Thanks in Advanceparapr wrote:
How can i get DDL Script in Oracle 11g database.
I am using windows as OS
Can anyone help me to get solution.
Thanks in AdvanceHUH?
might DBMS_METADATA.GET_DDL() provide what you desire? -
How to export view definitions
I'm having following issue:
I have created my own view definitions in Endeca Studio, via View Manager UI, and export them by following the recommendations found at https://wikis.oracle.com/display/endecainformationdiscovery/Export+View+Configuration.
Such recommendations are to create a graph that connects to Endeca Data Store and saves all view configuration in the required format for the LoadViewDefinitions graph.
Actually, I was able to create the graph and run it. After that, the xml file with the view definitions was created.
However, when I tried to run the LoadViewDefinitions graph, to import the definitions of the xml file to other data store, the following error came out:
Interpreter runtime exception in function substring on line 5 column 26 - 'String index out of range: -161'
By looking at the xml file and comparing it with other xml files, I could see that it contains only one long line with all the code, and I think this is the cause of the import failure.
Could anyone help me with this?
ThanksHi,
Not sure if I understood when you said to delete that white space from xml file. The thing is that the xml file contains only one long line with all code, like this:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><listEntitiesResponse xmlns="http://www.endeca.com/endeca-server/sconfig/1/0"><semanticEntity key="LandedCost" displayName="LandedCost"><definition>DEFINE LandedCost AS SELECT...
While other files that work are like this:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<listEntitiesResponse xmlns="http://www.endeca.com/endeca-server/sconfig/1/0">
<semanticEntity key="LandedCost" displayName="LandedCost">
<definition>
DEFINE LandedCost AS SELECT ...
What should I do with the one that does not work? Which white space are you referring to?
Thanks
Maybe you are looking for
-
Paul Riggott Missing (Programmer Needed)
The active members of this forum know how brilliant Paul Riggott is. I was fortunate to be the benificiary to Paul's genious as he so kindly offered his skills to me as he helped me create an entire JS application for use within Photoshop. Recently
-
What is with this error message?
Usually after my computer is on for a bit, iTunes begins to get an error message that says "STATUSWAIT0". Even restarting iTunes doesn't help it, the only way to fix it is to reboot the computer and then it will come up again after some time. It's pr
-
With the new seession in IE gives session error for new user
Hi, In new opened IE if i tries to login with new user. It is switching b/w the files in the status bar(ie., Header1.jsp and ListServicecall.jsp simultaneously) and at end the session error result will arise. But for the second time if i login with t
-
Audio files not playing correctly on website.
My husband's website just was rebuilt and we are both having trouble with his recording samples page. The Webdesigner says that it is working fine. When we go to play an audio track, then we click on another audio track the 1st audio track is suppose
-
I want clarification on unlocked 5s
So my dad is planning to get some iPhones for our family. I suggested to choose the T-mobile contract-free version so we don't have to worry about monthly fees and such (if that is how that works). So if we go with contract-free, I can basically: wat