Procedure/Package to compare User Schemas

Hello,
I'm looking for a way to compare the schema of two users. We have a group of developers that have their own schemas, and we need a way that we can find the differences between them.
I would greatly welcome any help or guidance provided.

The simplest I have been using is selecting everything from the views you wanna compare (user_objects, user_tables, user_indexes etc. etc.), spool the complete result to a different file per user and do a diff on unix (make sure you order by something). Although I wouldn't be surprised if there are more sofisticated tools to do this...
An example I used: (I only wanted to know object and constraint differences. The script assumes differences between multiple users on 2 different instances, but it should be easy to rewrite):
sqlplus $1 <<___EOF
set lines 100
set echo off
set feedback off
set heading off
set timing off
set long 40
col table_name a40 truncated
col constraint_type a8 truncated
col owner format a8 truncated
col object_type format a10 truncated
col object_name format a40 truncated
spool dbdiff1.lst
select owner, object_type, object_name from dba_objects where owner in
('USER1','USER2','USER3')
order by owner,object_type, object_name
select owner, table_name, constraint_type, search_condition from dba_constraints where owner in
('USER1','USER2','USER3')
order by owner,table_name, constraint_type, constraint_name
spool off
___EOF
sqlplus $2 <<___EOF
set lines 100
set echo off
set feedback off
set heading off
set timing off
set long 40
col table_name a40 truncated
col constraint_type a8 truncated
col owner format a8 truncated
col object_type format a10 truncated
col object_name format a40 truncated
spool dbdiff2.lst
select owner, object_type, object_name from dba_objects where owner in
('USER1','USER2','USER3')
order by owner,object_type, object_name
select owner, table_name, constraint_type, search_condition from dba_constraints where owner in
('USER1','USER2','USER3')
order by owner,table_name, constraint_type, constraint_name
spool off
___EOF
diff dbdiff1.lst dbdiff2.lst > dbdiff.out

Similar Messages

  • Procedure/package to change user password through plsql gateway

    I'm not sure is this the right place to ask, but I don't know anywhere better.
    I'm using Oracle 817 with the apache that bundled. I use the plsql gateway (mod_plsql). I want to create a page for user to change their password, however, I don't know how to verify the existing password of the user before changing to a new password. Also, how can I change the password, is there a standard procedure to do that?
    One more question, when I key in the following:
    http://myhost/pls/my_dad/my_schema.my_procedure
    the web server return a page with lots of cgi environment (assuming the my_procedure doesn't exist), how can I customise this page?
    thx.

    To ensure security of the Oracle database system and prevent unauthorized access to the Oracle database, it’s important for Oracle users to not only using strong and long Oracle passwords to avoid brute force or dictionary attacks, but also to change the Oracle user password regularly. Oracle users also have to change the password when the password has or going to expire, if database system administrator implements and enforces strict password control with PASSWORD_LIFE_TIME option for user profiles which limits the number of days the password can be used for authentication to login to the system.
    To change the Oracle password, users can use SQL*Plus or Oracle SQL and PL/SQL language interface administration tool such as Toad for Oracle. No matter what SQL apps you use, the commands and SQL query languages used to change the password are similar.
    There are two SQL command syntaxes that can be used to change Oracle database user password:
    ALTER USER user_name IDENTIFIED BY new_password;or (from Oracle8 and above):
    PASSWORD
    For above SQL query, if you need to change another user’s password, use the following command:
    PASSWORD user_name
    For PASSWORD command, after you press Enter, you will be prompted to input the old password and new password interactively. For example:
    SQL> password
    Changing password for DAVID
    Old password:
    New password:
    Retype new password: Note: You need to have enough privileges to change other Oracle user’s password.
    As the variable in italic implied by name, user_name is the user whose password wishes to be changed, and new_password is the new password to assign.
    As ALTER USER SQL syntax will send the new password to the Oracle database server unencrypted if use without Advanced Security Option, and thus expose to security risk, Oracle users should always use the PASSWORD command to change the Oracle user password.

  • Wwsec_api packaged procedures not accessed by other schema user.

    I am trying to use wwsec_api packaged procedure in portal application developed in another users schema and owned by that user. When I try to execute wwsec_api procedures it gives numeric or value error.
    could anyone tell what all permissions/grants to be set to access security package in other user's schema's portal application?

    Have you tried running provsyns.sql? It's detailed in the PDK.

  • Compare/merge models and datatypes,stored procedures,packages

    In the ddl scripts produces by compare/merge models functionality the stored procedures, packages and object types seems to be missing, it is a bug or the Data Modeler is designed in order to produce the stored procedures code only with the DDL generation functionality?
    Could be possible iwith the data modeler generate fully the scripts of the changes comparing the prodution and the development database?

    In the ddl scripts produces by compare/merge models functionality the stored procedures, packages and object types seems to be missing, it is a bug or the Data Modeler is designed in order to produce the stored procedures code only with the DDL generation functionality? It's not implemented - you can look at it as bug or missing functionality. Support for that will appear in future releases just matter of time - we didn't have support for packages in version 2.0.
    Could be possible iwith the data modeler generate fully the scripts of the changes comparing the prodution and the development database?You see some elements are missing - yes for the rest.
    Philip

  • Calling Stored Procedure with a different user name

    Hi,
    I am in the process of converting OracleClient based .NET 2.0 application to ODP.NET
    and while trying to replace an existing call to a stored procedure which is in another user schema(different user)
    the ORACLE Client(Microsoft) version worked fine with the following calling mechanism -
    USERNAME.PACKAGENAME.STOREDPROCEDURENAME
    Example : objCmd.CommandText ="*USERNAME*.*PACKAGENAME*.*STOREDPROCEDURENAME*"
    and it does not work when used with ODP.NET.
    I tried using-
    "@USERNAME.PACKAGENAME.STOREDPROCEDURENAME"
    still it does not work.
    Any help is appreciated?
    Thanks...!!
    Edited by: user4553639 on Mar 16, 2011 1:09 PM
    Got it resolved....had to change the Package. No code change needed on the .NET side.
    Edited by: user4553639 on Mar 17, 2011 1:08 PM

    Got it solved.

  • Compare 2 schemas and get the difference with .sql file.

    Hi,
    I am using ORACLE DATABASE 11g R2 and ORACLE Linux 5.
    I want to perform a very lengthy process and want to make it automated.
    I am having a software named as SVN. In which all the developers keep their updated scripts.
    We have 2 schema's one is used for developement and when all the development seems good we implement the scripts on the final schema which is used by testing people also.
    Now every day we need to check the modifications in the development schema, that we do by observing the updated scripts in the SVN software. Now we get the scripts which are modified.
    We will fire this scripts to a sample schema then we will compare the objects in this schema and the same objects in our final schema. If the objects in sample schema is different than the final schema it should give me the
    script to create the same type object in the final schema.
    Below is a proper example to explain :-
    Developement Schema :- 'DEV'
    SVN Script Schema :- 'SVNscript'
    Main Schema :- 'MAIN'
    1) On Monday developers modified/added 4 tables in the development schema names 'DEV' after working for a day they found that the changes are necessary and so checked-in in the SVN software.
    2) On tuesday morning we found 4 scripts which has been modified/added in the SVN.
    The Scripts were as follows :-
    1St table :- An extra column was added.
    2nd table :- An index was created on it.
    3rd table :- 2 Columns were dropped from it.
    4th table :- A new table is added in the schema.
    Now taking these 4 scripts i am going to execute it in a sample schema named :- SVNscript
    SVNscript schema will have now 4 tables with proper properties(columns,indexes,...). Now this is the final table structure as we want in our 'MAIN' schema .
    Coming to MAIN schema which is our most important schema and all the development work is finally posted here.Considering MAIN schema is having around 1000 tables,500 function/procedure/package and many more DB objects.
    I want to compare(one way compare) from SVNscript schema --> MAIN schema :- That the objects present in the SVNscripts schema is same or not in the MAIN schema. If its not same then this code should generate a .sql script for me which i should be able to fire on the MAIN schema.
    The output .sql scripts should be something like this :-
    1st Table :- Alter table add...
    2nd Table :- Create index on table...
    3rd Table :- Alter table drop...
    4th table :- Create table tablename...
    I found a link while trying this but it is not the perfect fit to my requirement
    http://www.dbspecialists.com/files/scripts/compare_schemas.sql
    Please let me know the best code to compare 2 schemas and get a .sql file as output of the difference.
    Thanks in advance.

    Yes I followed the tutorial properly this time. Still i have a few queries :-
    1) This is returning me the 'ALTER TABLE...' statement but how to make it more efficient to return all the DDL dependent on the table, Like index,trigger,view...
    2) I want to compare objects in a different schema on a different db. I have created an DBLINK but how to use it ... can i use it like
    DBMS_METADATA.OPEN('TABLE'," Network_link_name " );Can you please give me some clear about it.
    3) I created a table 'TAB1' with which i want to compare a 'TAB1' in other schema.I was not getting how to compare on remote dblink so,I created the same table with the following code in the same schema
    CREATE TABLE TAB1_OLD as select * from TAB1@DBLINK where 1=2;Now when i fire the below query to get the alter difference I get the following error :-
    SQL> SELECT get_table_alterddl('TAB1','TAB1_old') FROM dual;
    SELECT get_table_alterddl('TAB1','TAB1_old') FROM dual
    ORA-31603: object "TAB1_old" of type TABLE not found in schema "SVNCHECK"
    ORA-06512: at "SYS.DBMS_METADATA", line 5225
    ORA-06512: at "SYS.DBMS_METADATA", line 5189
    ORA-06512: at "SVNCHECK.GET_TABLE_SXML", line 17
    ORA-06512: at "SVNCHECK.COMPARE_TABLE_SXML", line 12
    ORA-06512: at "SVNCHECK.GET_TABLE_ALTERXML", line 11
    ORA-06512: at "SVNCHECK.GET_TABLE_ALTERDDL", line 11
    Can you please guide me why i am getting this error?
    I have made sure that TAB1_OLD table has been created and the entries are also present in the data dictionary tables.
    SQL> select * from tab1_old;
    EMPNO ENAME                  MGR DEPTNO
    ----- -------------------- ----- ------The only difference is that this table was created with CREATE TABLE AS SELECT statement ....
    Thanks.

  • Access package body in once schema by another

    I have package defined in one schema (A). How can another user (B) access the body of that package logged in as B?

    SQL> select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE     10.2.0.1.0     Production
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    SQL> connect o/o
    Connecte.
    SQL> create or replace package p is procedure p; end;
      2  /
    Package cree.
    SQL> create or replace package body p is procedure p is begin null;end; end;
      2  /
    Corps de package cree.
    SQL> grant execute on p to u;
    Autorisation de privileges (GRANT) acceptee.
    SQL> connect u/u
    Connecte.
    SQL> select * from all_source where owner='O';
    OWNER                      NAME                     TYPE
          LINE
    TEXT
    O                      P                     PACKAGE
          1
    package p is procedure p; end;
    O                      P                     PACKAGE BODY
          1
    package body p is procedure p is begin null;end; end;
    OWNER                      NAME                     TYPE
          LINE
    TEXT
    SQL>

  • Drop a  user/schema

    Under a user/schema (such as tester), I created tables, indexes, packages, stored procedures, functions, etc.
    1)Now If I issue a statement for dropping the user/schema, in order to delete the user/schema from the system, will those said tables, indexes, packages, stored procedures, functions, etc, be all deleted from the database system, too?
    2)My understanding that the user and the schema are actually the same thing. So to drop the user tester will also drop the schema tester, or vice versa. --Is this statement correct?
    Thanks

    scott,
    It's an eternal question : difference between schema and user.
    You create a user to connect in your db.
    This user, if granted, can read objects from others users;
    If this user, if granted, create any objects (tables, views, etc...), he create a schema. A schema is a set of object for which the user is the owner.
    Also, if you drop a user, you drop all his objects... and so his schema. We don't say that you drop schema, but you drop user, it is a little nuance...
    Nicolas.

  • Compare 2 schemas

    Hi,
    I need help for compare 2 schemas.
    Would like to know if there is any script to compare schema's
    I would want to compare the table name, column name, data type and also the
    size, if there is any difference,
    The DB objects diff. (packages,procedures,functions and triggers.etc...)
    I tried with PL/SQL editor and it shows the Case(upper and lower case) and white space diff...
    Thanks in Advance.

    for table_name:
    select table_name from dba_tables
    where owner='schema1'
    table_name not in (select table_name from dba_tables
    where owner='schema2')
    select table_name from dba_tables
    where owner='schema2'
    table_name not in (select table_name from dba_tables
    where owner='schema1')
    for column name:
    select table_name,column_name from dba_tab_columns
    where owner='schema1'
    (table_name,column_name) not in (select table_name,column_name from dba_tab_columns
    where owner='schema2')
    select table_name,column_name from dba_tab_columns
    where owner='schema2'
    (table_name,column_name) not in (select table_name,column_name from dba_tab_columns
    where owner='schema1')

  • How to restrict the user(Schema) from deleting the data from a table

    Hi All,
    I have scenario here.
    I want to know how to restrict a user(Schema) from deleting the values from a table created in the same schema.
    Below is the example.
    I have created a table employee in abc schema which has two values.
    EMPLOYEE
    ABC
    XYZ
    In the above scenario the abc user can only fire select query on the EMPLOYEE table.
    SELECT * FROM EMPLOYEE;
    He should not be able to use any other DML commands on that table.
    If he uses then Insufficient privileges error should be thrown.
    Can anyone please help me out on this.

    Hi,
    kumar0828 wrote:
    Hi Frank,
    Thanks for the reply.
    Can you please elaborate on how to add policies for a table for just firing a select DML statement on table.See the SQL Packages and Types manual first. It has examples. You can also search the web for examples. This is sometimes called "Virtual Private Database" or VPD.
    If you have problems, post a specific question here. Include CREATE TABLE and INSERT statements to create a table as it exists before the policies go into effect, the PL/SQL code to create the policies, and additonal DML statements that will be affected by the policies. Show what the table should contain after each of those DML statements.
    Always say which version of Oracle you're using. Confirm that you have Enterprise Edition.
    See the forum FAQ {message:id=9360002}
    The basic idea behind row-level security is that it generates a string that is automatically added to SELECT and/or DML statement WHERE clauses. For example, if user ABC is only allowed to query a table on Sunday, then you might write a function that returns the string
    USER  != 'ABC'
    OR      TO_CHAR (SYSDATE, 'DY', 'NLS_DATE_LANGUAGE=ENGLISH') = 'SUN'So whenever any user says
    SELECT  *
    FROM    table_x
    ;what actually runs is:
    SELECT  *
    FROM    table_x
    WHERE   USER  != 'ABC'
    OR      TO_CHAR (SYSDATE, 'DY', 'NLS_DATE_LANGUAGE=ENGLISH') = 'SUN'
    ;If you want to prevent any user from deleting rows, then the policy function can return just this string
    0 = 1Then, if somone says
    DELETE  employee
    ;what actually gets run is
    DELETE  employee
    WHERE   0 = 1
    ;No error will be raised, but no rows will be deleted.
    Once again, it would be simpler, more efficient, more robust and easier to maintain if you just created the table in a different schema, and not give DELETE privileges.
    Edited by: Frank Kulash on Nov 2, 2012 10:26 AM
    I just saw the previous response, which makes some additional good points (e.g., a user can always TRUNCATE his own tables). ALso, if user ABC applies a security policy to the table, then user ABC can also remove the policy, so if you really want to prevent user ABC from deleting rows, no matter how hard the user tries, then you need to create the policies in a different schema. If you're creating things in a different schema, then you might as well create the table in a different schema.

  • How to copy all tables, triggers, etc from one user schema to another

    Hello everybody!
    I am searching for a QUERY or Stored Procedure to copy the tables of one user schema to another schema.
    Should look kind of: Copy (Select * from all_objects where owner = 'UserIwantToCopyFrom') to user = 'UserIwantToCopyTO'
    I am sure that my example is rubbish but I tried to explain what I want to do.
    So is there a chance to do that within sql-code? I have to build a template of a user schema with hundreds of tables, triggers, etc and copy it to several other user schemas.
    Thanks for your advice!
    Jan

    There are numerous examples available.
    What you typically will want to do is:
    For the export use the job_mode => 'SCHEMA' option
    Export example
    http://www.oracle-base.com/articles/10g/OracleDataPump10g.php
    DECLARE
      l_dp_handle       NUMBER;
      l_last_job_state  VARCHAR2(30) := 'UNDEFINED';
      l_job_state       VARCHAR2(30) := 'UNDEFINED';
      l_sts             KU$_STATUS;
    BEGIN
      l_dp_handle := DBMS_DATAPUMP.open(
        operation   => 'EXPORT',
        job_mode    => 'SCHEMA',
        remote_link => NULL,
        job_name    => 'EMP_EXPORT',
        version     => 'LATEST');
      DBMS_DATAPUMP.add_file(
        handle    => l_dp_handle,
        filename  => 'SCOTT.dmp',
        directory => 'TEST_DIR');
      DBMS_DATAPUMP.add_file(
        handle    => l_dp_handle,
        filename  => 'SCOTT.log',
        directory => 'TEST_DIR',
        filetype  => DBMS_DATAPUMP.KU$_FILE_TYPE_LOG_FILE);
      DBMS_DATAPUMP.metadata_filter(
        handle => l_dp_handle,
        name   => 'SCHEMA_EXPR',
        value  => '= ''SCOTT''');
      DBMS_DATAPUMP.start_job(l_dp_handle);
      DBMS_DATAPUMP.detach(l_dp_handle);
    END;
    /for the import you will have to use the remap_schema option with:
    DBMS_DATAPUMP.METADATA_REMAP (
       handle      IN NUMBER,
       name        IN VARCHAR2,
       old_value   IN VARCHAR2,
       value       IN VARCHAR2,
       object_type IN VARCHAR2 DEFAULT NULL);There are much more details in the document that Thierry provided.

  • Help Required :Excel Upload Into Oracle Table Using PLSQL Procedure/Package

    Please Help , Urgent Help Needed.
    Requirement is to Upload Excel file Into Oracle Table Using PLSQL Procedure/Package.
    Case's are :
    1. Excel File is On Users/ Client PC.
    2. Application is on Remote Server(Oracle Forms D2k).
    3. User Is Using Application Using Terminal Server LogIn.
    4. So If User Will Use to GET_FILE_NAME() function of D2K to Get Excel File , D2k Will Try to pick File from That Remote Server(Bcs User Logind from Terminal Server Option).
    5. Cannot Use Util_File Package Or Oracle Directory to Place That File on Server.
    6. we are Using Oracle 8.7
    So Need Some PL/SQL Package or Fuction/ Procedure to Upload Excel file on User's Pc to Oracle Table.
    Please Guide me wd some Code. or with Some Pl/SQL Package, or With SOme Hint. Or any Link ....
    Jus help to Sort This Issue ........
    you can also write me on :
    [email protected], [email protected]

    I also Tried to Use This
    But How can i Use SQLLDR Command In Stored Procedure.
    Well IN SQL*PlUS it is successfull but in Stored Procedure /Package ,PL/SQL does not recognise the OS commands.
    So now my Question How can I recognise the SQLLDR Commnad in Stored Procedure.

  • Which user/schema executed query in V$SQLAREA

    I am looking on one row/query in view "V$SQLAREA" and want to which user/schema was used to log in to the database when that one query was executed. How i can get that schema name?
    Should i look this column maybe:
    V$SQLAREA
    PARSING_SCHEMA_NAME             VARCHAR2(30)      Schema name that was used to parse this child cursor( http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/dynviews_2129.htm )
    I have Java software that uses different database schemas/users to make connections to my database. And i want to know for one query which schema/user was used to connect to database before running the query.
    I think i need to join "V$SQLAREA" to view V$SESSION and there the column "USERNAME" tells me the connection user name for the executed query.
    V$SESSION
    USERNAME      VARCHAR2(30)      Oracle username
    ( http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/dynviews_2088.htm )Seems like i fail to join "V$SQLAREA" to view V$SESSION:
    select q.SQL_TEXT, q.sql_id, q.PARSING_SCHEMA_NAME, q.ADDRESS, q.last_active_time, s.USERNAME, s.SCHEMANAME from v$sqlarea q, v$session s
    where q.last_active_time > sysdate - 1
    and q.sql_text like 'DELETE FROM casino.lgngameoperationlog WHERE sessionCode%'
    and s.sql_address=q.address
    order by last_active_time desc
    no rows found
    select q.SQL_TEXT, q.sql_id, q.PARSING_SCHEMA_NAME, q.ADDRESS, q.last_active_time from v$sqlarea q
    where q.last_active_time > sysdate - 1
    and q.sql_text like 'DELETE FROM casino.lgngameoperationlog WHERE sessionCode%'
    order by last_active_time desc
    'DELETE FROM casino.lgngameoperationlog WHERE sessionCode = :1 and sessionType = :2';     51thfgbubkkg6;     JAVA;     0000000392523658;     28.10.2010 18:09:14;
    */

    I have Java software that uses different database schemas/users to make connections to my database. And i want to know for one query which schema/user was used to connect to database before running the query.If the SQL-text sits inside your Java code, that is the text does not sit inside some stored pl/sql program unit, then you can use parsing_schema_id, yes.
    If the SQL-text sits inside a stored procedure, then depending on how that procedure is defined (invoker rights or definer rights), you could use parsing_schema_id too (in the first case (invoker rights)).

  • View package body in another schema

    I have developers who want to view the code in the package body in another's schema.
    I know select text from all_source/ user_source works only for packages in your own schema.
    Granting system privelege 'create any procedure' allows the developer to view as well as update priveleges.
    As the owner of the objects what grants do I need to give to developers so that they can only view the code.

    You can grant select_catalog_role permissions to your developers. This will give your developers select access to all of the V$ views and DBA_% views. Then they can view the dba_source table to view other schema's package code..
    Regards,
    David

  • VIew of Package body in another schema in EA 3.0

    I would like the ability in SQL Developer to view the package body of another schema with the CREATE ANY PRIVILGE.
    For instance, in TOAD you can grant access to DBA_SOURCE or SELECT_CATALOG_ROLE and then be able to view another schema's package body.
    This is long overdue without having to log into that schema or granting CREATE ANY PRIVILEDGE to user.
    This one is really needed

    "CREATE ANY PRIVILEGE" is irrelevant to the ability of viewing the source owned by other users.
    Please provide exact script for creating a user, which is able to see the code, say in HR schema, via the query
    select * from all_source
    where owner = 'HR'
    and yet missing the nodes in the OtherUsers->Packages->PKG_A->PKG_A Body in the navigator.

Maybe you are looking for

  • Closing stock

    I have a query regarding one entry on closing stock. When we get rate difference from our vendor, we raise AP Credit Memo and select Service. And in GL A/c we select closing stock of plates. Because of this entry we are getting difference in Inventor

  • HD constantly needs repair

    If I were to run VERIFY DISK every day on my MacBook I would get the same results: files differ by one file and folders differ by one folder...requiring a REPAIR DISK. This is getting old...how can I determine which file is the culprit here? I obviou

  • Se le puede poner mac os x lion a una mac mini 2009

    quisiera sabes porfavor diganme  es snow leopard

  • Problem with SQLServerWriter failing to prepare snapshot

    I have been having a problem with a third party tool we are using to do farm backups on Sharepoint.   It is backing up the WFEs and app servers fine using VSS.. but when it comes time to backup the sql servers the SQLServerWriter keeps dying on me. 

  • How to round picture corners

    Hi, I love Adobe Photoshop Elements. I have gotten Version 10 lately and I have to say, Adobe does not make certain tasks easy. All I need is to have my pictures either cropped with rounded corners, or to have the pictures with rounded corners withou