Synonyms in schema

Hi,
I have some tables in schema X (ts1, ts2, ts3 and synonyms for those tables are t1, t2, t3)
I have another schema Y
there are some stored procedures in this schema which use to refer tables with table name in schema X ( select from x.ts1 where )
Now I was asked to change the procedures to refer synonyms rather than table name
(X.t1)
I have changed schema name. table name to synonym and tried to compile the procedure
its throwing an error
LINE/COL ERROR
26/5 PL/SQL: SQL Statement ignored
26/17 PL/SQL: ORA-00942: table or view does not exist
if I keep procedures with schema name.table name compilation is sucessful
if I am in toad session with user schema Y
I can see all synonyms related to schema X
what other grants do I need to overcome this error ?
Thanks,

I think your synonyms are not public.
Just check that.
Amardeep Sidhu

Similar Messages

  • Performance Problem: Synonym in Schema Referencing Synonym in Diff Schema

    Does anyone have any experience using a synonym in one schema that references another synonym in another schema? I found that if I do it this way, the performance drops considerably depending upon the SQL. It runs slow and in some cases I get Oracle errors (i.e. Invalid ROWID). If I change my synonym to reference the actual table in the other schema, it don't get the same degradation in performance.
    I'm curious if anyone has experienced the same problem and what options might be available to improve the situation. I lose the "semantic" layer by doing this - having to always reference the physical table instead of the synonym in the other schema.
    Thanks for any input or comments you might have.
    Sabert

    Only 2 schemas. Schema A has a table T1 with a public synonym S1. I am running sql against Schema B, however I have a private synonym S2 in this schema (B) that references synonym S1 in Schema A. Because I am using a synonym to reference another synonym in another schema I'm having performance issues. I tried a test and changed the S2 synonym in schema B to point to the table T1 instead of S1 in schema A and it performed much better. Just want to understand what I'm seeing here. This example might help:
    Schema A:
    "CREATE SYNONYM S1 FOR T1"
    Schema B (I'm running my sql against this schema, but my synonym points to table in schema A):
    "CREATE SYNONYM S2 FOR A.S1"
    "INSERT INTO XXX SELECT * FROM S2"
    I had performance issues with this synonym to synonym, so I changed it to synonym to table:
    "CREATE SYNONYM S2 FOR A.T1"
    Again, with the change in reference from a synonym to the actual table, things seem to work better. Hope this makes sense.
    Thanks for your help.

  • Export synonyms with schema

    Hi all
    I am trying to export synonyms with the schema, but they do not show on the generated script.
    How can I add the synonyms?
    thanks
    J

    Exactly what synonyms are you trying to export? If they are owned by (i.e., exist within) the schema you are exporting, then they should be exported unless you uncheck the "Synonyms" box. If instead you want to export the synonyms that point to objects in the schema you are exporting, but are owned by another schema, then you can only do it by exporting that second schema separately.
    For instance, if you export schema "A' and it has synonyms to itself or to some other schema (or schemas), then they should be part of the script. If however schema "B" has synonyms pointing to schema "A" and you export schema "A" all you will get is schema "A"s objects; schema "B"s synonyms will not be included since they belong to it and not schema "A".
    Hope this helps.
    Ed. H.

  • Table T1 in Schema A, Synonym T1 in Schema B, View V1 in Schema B.

    Hi,
    There are two schemas Schema A and Schema B
    Table-> XML_TABLE is in Schema A.
    If I create a view V1 with the following query:
    SELECT *
    FROM XML_TABLE t
    WHERE XMLEXISTS (
    'declare namespace nmsp ="name:namespace"; fn:collection("oradb:/PUBLIC/Table2")/ROW[ColumnName=$d/nmsp:Colmn2/nmsp:id]'
    PASSING t.textxml AS "d")
    My XML Indexes are used and output is fast.
    BUT in Schema B also I have a synonym for table XML_TABLE pointing to the table in Schema A.
    And I create a similar view v1 in schema B also using the same query as above.
    BUT this doesn't use indexes. I can see that in the plan and also query never gets executed.
    So IS IT correct to have table in schema A, Synonym in Schema B for this table and View in Schema B for this.
    How should I make it work
    OR
    Should I remove the view to Schema A only?
    Thanks..
    Edited by: user8941550 on Dec 12, 2012 11:56 PM

    user8941550 wrote:
    Hi,
    There are two schemas Schema A and Schema B
    Table-> XML_TABLE is in Schema A.
    If I create a view V1 with the following query:
    SELECT *
    FROM XML_TABLE t
    WHERE XMLEXISTS (
    'declare namespace nmsp ="name:namespace"; fn:collection("oradb:/PUBLIC/Table2")/ROW[ColumnName=$d/nmsp:Colmn2/nmsp:id]'
    PASSING t.textxml AS "d")
    My XML Indexes are used and output is fast.
    BUT in Schema B also I have a synonym for table XML_TABLE pointing to the table in Schema A.
    And I create a similar view v1 in schema B also using the same query as above.
    BUT this doesn't use indexes. I can see that in the plan and also query never gets executed.Ok, I was following you to that point, but what do you mean the query never gets executed?
    So IS IT correct to have table in schema A, Synonym in Schema B for this table and View in Schema B for this.Well, it's not incorrect. Perhaps more tidy to just have the view defined in schema A along with the table, if it's going to be used in schema A as well, and then have a synonym for schema B to use that view.
    How should I make it work
    OR
    Should I remove the view to Schema A only?Perhaps you could post an example of your table with some example data for people to use, along with the views and statement to set up the synonyms, so it can be reproduced by others to see what's going on. Also, post the explain plans you're referring to.

  • Error while import schema in HANA DB

    Hi...
    I am trying to perform an export-import of a HANA DB user instance at schema level including all objects (in my case tables and synonyms) and data.
    Export and Import works very well except importing a schema which contains a synonym referred to other existing schema .
    Here is a test case
    - Schema A with a Table and Schema B to contain a synonym for schema A's table.
    - Exported both schemas to CSV which is done successfully and everything looked ok in export location.
    - Imported Schema A and then Schema B with the following command.
    Command:
    IMPORT "<bkup_schema>"."*" FROM '<bkp_location>' WITH RENAME SCHEMA <bkup_schema> TO <brand_new_schema>;
    The schema A (with table) imported fine.  Schema B (with synonym) gives the below error :
    "SAP DBTech JDBC: [2048]: column store error: table import failed:  [2003] An index already exists with the same name "
    When trying to use "REPLACE" clause in the command the error changes as below:
    SAP DBTech JDBC: [2048]: column store error: table import failed:  [30117] Binary import failed (cannot execute drop statement)
    Has anybody faced this type of error before??

    Folks, I am running into the same issue. What I figure out was the following:
    1) I turn off the autocommit
    2) I run the import for the first time
    import "<SCHEMA_NAME>"."*" as binary from '<location>' with replace;
    rollback;
    3) I get the error as described
    SAP DBTech JDBC: [2048]: column store error: table import failed:  [30117] Binary import failed (cannot execute drop statement)
    4) I run this import once again and commit and surprisingly the error is gone and the import is successful.
    import "<SCHEMA_NAME>"."*" as binary from '<location>' with replace;
    commit;

  • PL/SQL Web services working with synonyms but not parameters Collection

    Hi
    I am Using JDeveloper 10.1.3.1.0
    i could able to test successfully the PL/SQL web services with the synonyms.I created the PL/SQL web services in 'MKI' schema and then i dropped the objects from the MKI schema and launched the same in 'BAS' Schema and given grants to MKI schema and Created the Local synonyms in Schema 'MKI' and now when i test the PL/SQL web service, it is working successfully.
    There was problem with passing the collection types as parameters in web services in that case it is giving the following Error
    "Internal Server Error (Caught exception while handling request: java.rmi.RemoteException: java.sql.SQLException: Internal Error)"
    Could any one suggest me the reason for the above error?
    Regards
    Malathi

    Just a clarification about the problem.
    Even though, if an exception is raised, the Connection object will be eventually closed(), it may take a while and if there are lots of users getting exceptions at the same time the connection pool can quickly run out of connections (correct me if I am wrong please.)
    That is why we think the Connection object should be immediately closed in the case of an exception is raised and we are looking for a fix for this.
    Thanks
    Luis

  • No Records When Query Using Synonym

    Hello
    I have a view called v_employees in schema scott and select grant is provided to schema tom in same database.
    When I run a sql query from schema scott I could see records as results.
    I have a created a synonym in schema tom
    CREATE SYNONYM EMPLOYEES FOR scott.v_employees.When I run .select * from EMPLOYEES. from schema tom, I cannot see any results.
    What could be the reason for this?

    jeneesh wrote:
    Please post the query of the view..
    select text
    from dba_views
    where view_name = 'V_EMPLOYEES'
    and owner = 'SCOTT';
    This return
    select * from v_dept d, v_emp emp e
    where d.emp_no = e.empnoI have given grant select on all underlying objects to user tom, but not able to see any results.
    Cannot create public synonym for this user.
    Regards

  • Can't view private synonyms in OWB 9.2.0.2

    Hi All,
    I have created a number of private synonyms in Schema A for objects that exist in Schema B. When querying these tables via SQLPLUS (whilst in Schema A) I have no problems but I can not see these synonyms when trying an import in OWB (my Source module is connect to Schema A). I have checked the "Use a synonym to look up objects" checkbox but I still only see physical objects in my shema and not synonyms.
    Any help would be hugely appreciated.
    Kind Regards
    Mitesh

    I would like to add that I have created the synonyms in SchemaA for object in SchemaB across using a DB_LINK. When I create the synonyms without the use of a db_link I have no problems but when using it I do?

  • ORACLE STREAMS CAPTURE/PROPAGATE  with Synonyms

    In Source
    CISADM -- Stores All objects
    CISUSER -- Stores Synonyms of CISADM
    In Target
    CISADM -- Stores All objects
    CISUSER -- Stores Synonyms of CISADM
    Streams implemented successfully on CISADM schema.
    What ever changes happening in source CISADM, that are propagated successfully in target CISADM.
    Now the issue is any changes made through source CISUSER(Synonyms of CISADM), they are not propagating to target CISADM.
    Thanks,
    San

    Hi San,
    When you make any changes in CISADM objects of source through synonyms from CISUSER , they will be done in CISADM objects of source as well as replicated successfully in CISADM of destination (replicated database/schema).
    See following test case for reference.
    (Consider apps = your primary schema and testuser as your schema having synonyms. apps schema has been replicated using streams.).
    From, primary database's main schema
    SQL&gt; grant insert,update,delete, select on xyz to testuser;
    Grant succeeded.
    SQL&gt; select * from xyz;
    N
    1
    2
    3
    4
    From testuser schema of primary database:
    SQL&gt; select * from apps.xyz;
    N
    1
    2
    3
    4
    SQL&gt; create synonym xyz for apps.xyz;
    Synonym created.
    SQL&gt; select * from xyz;
    N
    1
    2
    3
    4
    SQL&gt; insert into xyz values(6);
    1 row created.
    SQL&gt; /
    1 row created.
    SQL&gt; /
    1 row created.
    SQL&gt; commit;
    Commit complete.
    SQL&gt; select * from xyz;
    N
    6
    6
    6
    1
    2
    3
    4
    7 rows selected.
    From apps schema of primary database:
    SQL&gt; select * from xyz;
    N
    6
    6
    6
    1
    2
    3
    4
    7 rows selected.
    SQL&gt;
    From apps schema of replicated database:
    SQL&gt; select * from xyz;
    N
    6
    6
    6
    1
    2
    3
    4
    7 rows selected.
    SQL&gt;
    Hope this helps..
    Regards,
    Dipali..
    Edited by: Dipali on Sep 16, 2008 4:31 AM

  • Generating DDL of table from synonym

    Hi All,
    I have synonyms in one schema A, and the original corresponding tables of those synonyms is in other schema B. Both the schema's are in integration server and I have only command prompt mode to work with and I can log in to only Schema A.
    I want to generate the DDL's of those tables in schema B using synonyms in schema A.
    Is this possible ? If yes Please help.
    I am using Oracle 9i.
    Thanks
    -AKJ
    Message was edited by:
    user554502

    The synonym itself won't do you much good.
    But, presumably you have at least select privileges on the real table.
    You can then query meta-data related to that table from the ALL_ views
    Example:
    select * from all_constraints where owner = 'B' and table_name = 'THE_TABLE';
    To get the ddl, check out DBMS_METADATA.GET_DDL (10g)
    select DBMS_METADATA.GET_DDL('TABLE','THE_TABLE') from dual;
    Message was edited by:
    dainge

  • Force Synonym

    Hi,
    Oracle give creation of view with the option Force and Noforce by default it is no force. so why not oracle has given same facility to Synonym. what i understand with the force option of View oracle check the existence of the view when any dml is fired on that view , same could be done with the synonym.

    Hi and welcome to the forum!
    FORCE
    *Specify FORCE if you want to create the view regardless of whether the base tables of the view or the referenced object types exist or the owner of the schema containing the view has privileges on them.* These conditions must be true before any SELECT, INSERT, UPDATE, or DELETE statements can be issued against the view.If the view definition contains any constraints, CREATE VIEW ... FORCE will fail if the base table does not exist or the referenced object type does not exist. CREATE VIEW ... FORCE will also fail if the view definition names a constraint that does not exist.>
    [For Clause of Create Synonym|http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_7001.htm#CJAJCDDF]
    Specify the object for which the synonym is created. The schema object for which you are creating the synonym can be of the following types:* Table or object table
    * View or object view
    * Sequence
    * Stored procedure, function, or package
    * Materialized view
    * Java class schema object
    * User-defined object type
    * Synonym
    The schema object need not currently exist and you need not have privileges to access the object.>
    What is your question exactly?

  • View Column info not displaying in Columns Tab

    Running XP SP2 and SQL Developer 1.5.1 5440
    When looking at views that are using tables from another schema. I don't see any of the columns information. I have DBA role
    In rel 1.1.2.25 2579 I see them just fine. (Both loaded on machine right now)
    Is this a bug or do I have a setting problem?

    Barry,
    As a "disclaimer", the points below are based on my usage of SQL Developer and things that bug me about how it works or doesn't work - I know that there are more important things to fix than a number of these.
    On to the basics ... and the most basic of the basics for a tool like SQL Developer:
    1) Problems with data dictionary queries in navigator or object tabs:
    - Triggers not listed in Table tab if trigger owned by different schema to table owner
    - Index columns not listed in Table tab if index owned by different schema to table owner
    - View columns not listed in View tab if view owned by different schema to current user
    - Dependencies not listed in Table/View tab if other object owned by different schema to object owner
    - Performance of Table Node (outer join added in 1.5.1)
    - there are a lot of other posts about the supplied data dictionary queries not producing the right results and I often find that I am querying the data dictionary directly in a SQL Worksheet for information that should be correct in the navigator/object tabs
    Basic things that I expect to work in a tool like SQL Developer (or to work given that they have been included):
    1) Popup Describe problems
    - schema name is case sensitive, so doesn't find owner.object
    - synonym overrides schema name (OWNER.OBJECT will describe local OBJECT synonym instead of OWNER's object)
    - position based object name selection includes punctuation
    2) Bind variables that work properly in PL/SQL (both Execute Statement and Run Script)
    3) Package decomposition in object navigator doesn't report variables or constants of custom types and lists object.column%type constants as "constant"
    4) Exporting query results re-executes query to display Export dialog - this presents as SQL Developer freezing after selecting the Export menu option for queries that take a long time for first record to appear
    I would use SQL Developer more (or more of SQL Developer) if:
    1) More integrated file based development - I still do the bulk of my object creation (largely PL/SQL and views) editing in Wordpad and running via SQL*Plus largely because I get better error reporting.
    - display the compile message tab when using the compile button for a file
    - show errors doesn't work for views
    2) Running Reports hang SQL Developer - I still have my SQL scripts for my common queries, which I can run through SQL Worksheet in a much friendlier fashion (I can cancel them and they don't hang SQL Dev) than I can run reports
    Problems that detract from the "polish" of SQL Developer, but don't really have a big impact on usage but discourage me from trying to "convert" non-techie TOAD using colleagues:
    1) Multiple TNSNAMES files read - generates multiple entries
    2) Export of long string literals causes ORA-972 error
    3) "Statement Processed" feedback is extremely sensitive to spaces ("create Statement Processed" where two spaces between the create and view keywords) and assumes simple statements ("create unique Statement Processed" or "create or replace force Statement Processed" as examples)
    I think that makes 10 basics to fix (although some as just issues that make the tool look unpolished), however, it does seem as though testing in the following areas could be significantly better:
    1) Regression testing - a number of bugs seem to crop up again after being fixed in earlier versions
    2) Navigator/object tab queries - especially with multi-schema applications (ie Oracle eBusiness Suite) and just generally objects owned by other schemas
    3) Performance with large DBs in terms of object count (ie Oracle eBusiness Suite)
    As a final note, it is my impression that SQL Developer development has been unbalanced in focusing too much on including new functionality (which is good) and not enough on getting existing functionality right (which is better).
    I hope this helps (and wasn't too long) ...
    theFurryOne

  • Help needed pls!!!!

    1.I have 2 schema a and b
    2.I dont have priviledge to create procedure in schema a but i have in schema b.So I created procedure in schema b which will update the synonyms in schema a
    3.Inside the procedure created under the schema b ? Can I use update a.<synonyn name>
    where <> ;
    Getting error : insufficient privilege to access object
    Can I update another schema's object from another schema ?

    Yes! but what u need is the privillages granted by a. Since a is the owner of the object a must grant the privilleges on that synonym to b.

  • Not showing tables, views, ... in vs2010

    Hi,
    I installed ODP.net + ODT (11i) for use with vs2010 & oracle 10.02.0010 (to be upgraded to oracle 11).
    The product installed just fine, I can connect to the database using ODP and ODBC.
    However, when connecting with ODP in vs2010 I can't see any tables, views or stored procedures (can't see anything really). When using ODBC, everything works: I see all the tables, views etc that are in the database, and I can query them.
    I also tried to execute a query using the ODP.net, and it gave me: ORA-00942: table or view does not exist.
    I did a search on the forums, but none of the solutions provided, changed anything for me.
    Does anyone have any ideas?
    Edited by: user13493229 on 18-mei-2011 11:05

    Hi,
    First of all, make sure you see "ODP.NET" in the connection dialog on Server Explorer.
    Next, check the "Filters" tab of the connection dialog. By default we block public synonyms and schema objects that you do not own.
    If you still can't see objects, then most likely your DBA has not given you enough privileges to use these tools.
    Try looking at the advice I gave in the following thread explaining how to turn on ODP.NET tracing. First look to see the SQL involved in the ORA-942.
    Then look at the other SQL we issue and see why you are not able to get any rows from it.
    vs2010 ORA-00942 table or view does not exist

  • Oracle SQL Developer 3.1 Migration Third Party Databases Issues

    Hi,
    i had following issues with migrating from db2 v8 to oracle 11.2.
    Online:
    Due to missing privileges and roles for user db user migrations some steps have failed (CREATE USER -> ORA-01031 ...).
    After correcting this like described in "Creating a Database User for the Migration Repository" in sqldev online help this has worked.
    The problems are:
    a) on the overview page at the end of the migration assistent all steps (CAPTURE, CONVERT, GENERATE, DATAMOVE) are shown as complete, even if nothing has done
    b) on page 6/9 into migration assistant all changes for datatype convertion are ignored, for example CHAR to VARCHAR2
    c) generated files are not visible, even if you mark refresh on file view
    d) after restarting sqldev, generarted files are visible in file view, but when you add generated files to svn error message "svn: File: xxx has inconsitent newlines" is shown
    e) after sucessful migration on opened migration project pane "data quality" sourcenumrows are NULL, even if they always NOT NULL and count(*) on any table on both sites are equal
    Offline:
    Generated skripts contains errors:
    ./startDump.sh: line 157: syntax error near unexpected token `done'
    '/startDump.sh: line 157: `done < "schemas.dat"
    Can anybody help?
    Thanks in advance
    André

    Hi kgronau,
    thanks for your fast answer.
    Today i have found 2 new issue.
    When you have opened a migration project from repository, on pane "data quality" sourcenumrows are always null
    and
    sourcename and targetname shows always databse object names from the database on the first migration project in repository independently of extra section in drop down box model and source.
    kgronau wrote:
    André,
    I used SQL Dev 3.1 and I captured a DB2 database. Then I've changed the rule to map char to varchar2 and started the migration.
    When I now check out my custom tables all all of them that had in the source model a char column are now using varchar2.I have tried to changed dataype for target database in place over the drop down box, not the edit rule button. It's a little bit confusing to have this option, when it doesn't works.
    After using the edit rule button, all works fine. Just the summary page 9/9 doesn't report changed datatype assignment.
    >
    Could you please explain what you mean with your option c and d?c)
    Yes i'm meaning View -> Files. Sorry but on german windows i have just german menu items. That is sometimes tricky to retranslate for support questions and also not helpful when using the online help where all menu items referenced in english :-(
    (Do you have an ideo how can i configure sqldev with english menu aon german windows?)
    I think, this problemn is special for output folders under subversion control.
    d)
    Generated Files after the end of the migration are just visible in output folders under subversion control after restarting sqldev
    >
    Edited by: kgronau on Mar 7, 2012 12:30 PM
    Are you talking about Opening a File viewer window (View -> Files)? In my case I have chosen d:\temp\DB2 as output and monitored it during the migration. It isn't refreshed until I manually click on the refresh button - but once the migration has finished and written the output and when I then click on the refresh button I'll see all the directories and the files included.
    Edited by: kgronau on Mar 7, 2012 12:39 PM
    When a migration has finished then SQL Developer 3.1 now creates in the top directory an unload_script.sh file which calls the other unload scripts.That's right, all scripts are generated.
    Also the data unload scripts were created - I need to find a DB2 on Unix to check the script - a quick check of the windows scripts worked correctly.
    Edited by: kgronau on Mar 7, 2012 1:22 PM
    These unload shell scripts to unload the data out of a DB2 database are also working.
    Unfortunately I'm not able to test the shell script used for a source model unload as my UDB is running on Windows.
    Didn't the online source model collection work? For me it looks like it did as you mentioned you changed the char data types to varchar2 and this requires already a connection to the source database - except you used the scripts that were generated using the startDump.sh which has failed. Yes, online source model collection did work. Just the unix shell script produces an error on the source unix system with db2. Please see below th generated script.
    So please provide here some more details../startDump.sh was startet for testing purposes without any arguments
    ./startDump.sh: line 157: syntax error near unexpected token `done'
    '/startDump.sh: line 157: `done < "
    if [[ $# != 3 ]]; then
    echo "Usage: startDump <database> <user> <password>";
    exit 1;
    fi
    ROWTAG="'<row>'";
    ENDROWTAG="'</row>'";
    COLTAG="'<col><![CDATA['";
    ENDCOLTAG="']]></col>'";
    # Clear any other dat files
    echo "Clearing older data files"
    rm -f *.dat
    echo "Connnecting to $1 as $2";
    db2 -r connect.dat "connect to $1 user $2 using $3";
    if [[ $? != 0 ]]; then
    echo "Connection failed.";
    exit 20;
    fi
    # GET SCHEMA QUERY.
    echo "Get all schemas";
    db2 +o -x -r schemas.dat "select SCHEMANAME SCHEMA_NAME from SYSCAT.SCHEMATA WHERE DEFINER <> 'SYSIBM' AND
    SCHEMANAME <> 'NULLID' AND SCHEMANAME <> 'SQLJ'
    AND SCHEMANAME <> 'SYSTOOLS'";
    if [[ $? != 0 ]]; then
    echo "Get schemas failed.";
    exit 30;
    fi
    # Loop through file containing schema names and extract db objects for each of them
    while read SCHEMA_NAME
    do
    # Create schema directory
    rm -rf "${SCHEMA_NAME}";
    mkdir "${SCHEMA_NAME}";
    if [[ $? != 0 ]]; then
    echo "Could not create schema directory ${SCHEMA_NAME}.";
    exit 40;
    fi
    echo "Get all tables for schema $SCHEMA_NAME";
    tablesFile="${SCHEMA_NAME}/""tables.dat";
    # GET TABLES QUERY. */
    db2 -x +o -r $tablesFile "select "$ROWTAG", "$COLTAG"||COLUMNS.TABSCHEMA||"$ENDCOLTAG", "$COLTAG"||COLUMNS.TABNAME||"$ENDCOLTAG",
    "$COLTAG"||COLUMNS.COLNAME||"$ENDCOLTAG", "$COLTAG"||(CASE WHEN (COLUMNS.CODEPAGE = 0 and (COLUMNS.TYPENAME = 'VARCHAR' OR COLUMNS.TYPENAME = 'CHAR'
    OR COLUMNS.TYPENAME = 'LONG VARCHAR' OR COLUMNS.TYPENAME = 'CHARACTER')) THEN COLUMNS.TYPENAME || ' FOR BIT DATA'
    ELSE COLUMNS.TYPENAME END)||"$ENDCOLTAG", "$COLTAG"||CHAR(COLUMNS.LENGTH)||"$ENDCOLTAG",
    "$COLTAG"||CHAR(COLUMNS.SCALE)||"$ENDCOLTAG", "$COLTAG"||COLUMNS.NULLS||"$ENDCOLTAG",
    "$COLTAG"||COALESCE(COLUMNS.DEFAULT, '')||"$ENDCOLTAG", "$ENDROWTAG" from
    SYSCAT.COLUMNS COLUMNS, SYSCAT.TABLES TABLES WHERE
    COLUMNS.TABSCHEMA = '${SCHEMA_NAME}' AND
    COLUMNS.TABNAME = TABLES.TABNAME AND
    COLUMNS.TABSCHEMA = TABLES.TABSCHEMA AND
    TABLES.TYPE = 'T'
    ORDER BY COLUMNS.TABNAME, COLUMNS.COLNO";
    if [[ $? != 0 ]]; then
    echo "No tables found.";
    fi
    # GET SYNONYMS QUERY. */
    echo "Get all synonyms for schema $SCHEMA_NAME";
    synonymsFile="${SCHEMA_NAME}/""synonyms.dat";
    db2 -x +o -r $synonymsFile "select "$ROWTAG", "$COLTAG"||TABNAME||"$ENDCOLTAG", "$COLTAG"||BASE_TABSCHEMA||"$ENDCOLTAG",
    "$COLTAG"||BASE_TABNAME||"$ENDCOLTAG", "$ENDROWTAG" from syscat.tables
    where tabschema = '${SCHEMA_NAME}' and type = 'A'";
    if [[ $? != 0 ]]; then
    echo "No synonyms found.";
    fi
    # GET VIEW QUERY. */
    echo "Get all views for schema $SCHEMA_NAME";
    viewsFile="${SCHEMA_NAME}/""views.dat";
    db2 -x +o -r $viewsFile "select "$ROWTAG", "$COLTAG"||VIEWSCHEMA||"$ENDCOLTAG", "$COLTAG"||VIEWNAME||"$ENDCOLTAG",
    "$COLTAG"||COALESCE(TEXT, '')||"$ENDCOLTAG",
    "$COLTAG"||DEFINER||"$ENDCOLTAG", "$COLTAG"||READONLY||"$ENDCOLTAG", "$COLTAG"||VALID||"$ENDCOLTAG", "$ENDROWTAG"
    from syscat.views
    WHERE VIEWSCHEMA = '${SCHEMA_NAME}'
    ORDER BY VIEWNAME";
    if [[ $? != 0 ]]; then
    echo "No views found.";
    fi
    # GET INDEXES QUERY. */
    echo "Get all indexes for schema $SCHEMA_NAME";
    indexesFile="${SCHEMA_NAME}/""indexes.dat";
    db2 -x +o -r $indexesFile "select "$ROWTAG", "$COLTAG"||INDSCHEMA||"$ENDCOLTAG", "$COLTAG"||INDNAME||"$ENDCOLTAG",
    "$COLTAG"||TABSCHEMA||"$ENDCOLTAG", "$COLTAG"||TABNAME||"$ENDCOLTAG", "$COLTAG"||INDEXTYPE||"$ENDCOLTAG",
    "$COLTAG"||UNIQUERULE||"$ENDCOLTAG", "$ENDROWTAG" from SYSCAT.INDEXES
    WHERE INDSCHEMA = '${SCHEMA_NAME}' AND UNIQUERULE <> 'P'
    ORDER BY TABNAME, INDNAME";
    if [[ $? != 0 ]]; then
    echo "No indexes found.";
    fi
    # GET INDEX DETAILS QUERY. */
    echo "Get all index details for schema $SCHEMA_NAME";
    indexeDetailsFile="${SCHEMA_NAME}/""indexDetails.dat";
    db2 -x +o -r $indexeDetailsFile "select "$ROWTAG", "$COLTAG"||INDSCHEMA||"$ENDCOLTAG", "$COLTAG"||INDNAME||"$ENDCOLTAG",
    "$COLTAG"||COLNAME||"$ENDCOLTAG", "$COLTAG"||CHAR(COLSEQ)||"$ENDCOLTAG", "$ENDROWTAG" from SYSCAT.INDEXCOLUSE
    WHERE INDSCHEMA = '${SCHEMA_NAME}'";
    if [[ $? != 0 ]]; then
    echo "No index details found.";
    fi
    # GET TRIGGERS QUERY. */
    echo "Get all triggers for schema $SCHEMA_NAME";
    triggersFile="${SCHEMA_NAME}/""triggers.dat";
    db2 -x +o -r $triggersFile "select "$ROWTAG", "$COLTAG"||TRIGSCHEMA||"$ENDCOLTAG",
    "$COLTAG"||TRIGNAME||"$ENDCOLTAG", "$COLTAG"||DEFINER||"$ENDCOLTAG", "$COLTAG"||TABSCHEMA||"$ENDCOLTAG",
    "$COLTAG"||TABNAME||"$ENDCOLTAG", "$COLTAG"||TRIGEVENT||"$ENDCOLTAG", "$COLTAG"||VALID||"$ENDCOLTAG",
    "$COLTAG"||COALESCE(TEXT, '')||"$ENDCOLTAG",
    "$COLTAG"||COALESCE(REMARKS, '')||"$ENDCOLTAG", "$ENDROWTAG"
    from SYSCAT.TRIGGERS
    WHERE TRIGSCHEMA = '${SCHEMA_NAME}'";
    if [[ $? != 0 ]]; then
    echo "No triggers found.";
    fi
    # The for GET Promary Key CONSTRAINT QUERY. */
    echo "Get all primary keys for schema $SCHEMA_NAME";
    primarykeysFile="${SCHEMA_NAME}/""primarykeys.dat";
    db2 -x +o -r $primarykeysFile "select "$ROWTAG", "$COLTAG"||X.CONSTNAME||"$ENDCOLTAG", "$COLTAG"||X.TYPE||"$ENDCOLTAG",
    "$COLTAG"||X.TABSCHEMA||"$ENDCOLTAG", "$COLTAG"||X.TABNAME||"$ENDCOLTAG", "$COLTAG"||Z.COLNAME||"$ENDCOLTAG",
    "$COLTAG"||CHAR(Z.COLSEQ)||"$ENDCOLTAG", "$COLTAG"||COALESCE(X.REMARKS, '')||"$ENDCOLTAG", "$ENDROWTAG" from
    (select CONSTNAME, TYPE, TABSCHEMA, TABNAME, REMARKS from SYSCAT.TABCONST where (type = 'P' OR type = 'U')) X
    FULL OUTER JOIN
    (select COLNAME, COLSEQ, CONSTNAME, TABSCHEMA, TABNAME from SYSCAT.KEYCOLUSE) Z
    on
    (X.CONSTNAME = Z.CONSTNAME and X.TABSCHEMA = Z.TABSCHEMA and X.TABNAME = Z.TABNAME)
    WHERE X.TABSCHEMA='${SCHEMA_NAME}'
    ORDER BY X.CONSTNAME";
    if [[ $? != 0 ]]; then
    echo "No primary keys found.";
    fi
    # The for GET Check constraints QUERY. */
    echo "Get all Check constraints for schema $SCHEMA_NAME";
    constraintsFile="${SCHEMA_NAME}/""checkConstraints.dat";
    db2 -x +o -r $constraintsFile "SELECT "$ROWTAG", "$COLTAG"||A.CONSTNAME||"$ENDCOLTAG", "$COLTAG"|| COALESCE(TEXT, '') ||"$ENDCOLTAG", "$COLTAG"|| A.TABSCHEMA||"$ENDCOLTAG", "$COLTAG"|| A.TABNAME ||"$ENDCOLTAG", "$COLTAG"|| COLNAME ||"$ENDCOLTAG", "$ENDROWTAG" FROM SYSCAT.CHECKS A , SYSCAT.COLCHECKS B
    WHERE A.CONSTNAME = B.CONSTNAME AND A.TABSCHEMA = B.TABSCHEMA AND A.TABNAME=B.TABNAME AND A.TABSCHEMA = '${SCHEMA_NAME}'";
    if [[ $? != 0 ]]; then
    echo "No check constraints found.";
    fi
    done < "schemas.dat"
    # GET PROCEDURES QUERY. */
    . getProcedures.sh schemas.dat
    # The for GET Foreign Key CONSTRAINT QUERY. */
    . getForeignKeys.sh schemas.dat

Maybe you are looking for