Query to find dropped users in database

Hi i have requirement to drop all invalid objects in database where user no longer exists in database, it is documented by oracle that if a cascade drop is performed on a userid that objects like MV & synonyms etc.. will become INVALID but will not be dropped from database.
Anybody has any idea how we can find such INVALID objects of users whose id is dropped from database.
Appreciate your help in advance.
Thanks
Abhinay

It is documented that when you issue DROP USER some_user CASCADE user and all objects owned by that user are dropped. And if object is dropped it simply doesn't exist and therefore can be neither VALID nor INVALID. Unless you are talking about objects owned by some other user that is referencing dropped user object. Something like:
SQL> create user u1 identified by u1 default tablespace users quota unlimited on users;
User created.
SQL> create user u2 identified by u2 default tablespace users quota unlimited on users;
User created.
SQL> create table u1.tbl as select * from dual;
Table created.
SQL> grant select on u1.tbl to u2;
Grant succeeded.
SQL> create view u2.u1_tbl_vw as select * from u1.tbl;
View created.
SQL> select object_name,object_type,status from dba_objects where owner = 'U2';
OBJECT_NAME     OBJECT_TYPE             STATUS
U1_TBL_VW       VIEW                    VALID
SQL> drop user u1 cascade;
User dropped.
SQL> select object_name,object_type,status from dba_objects where owner = 'U2';
OBJECT_NAME     OBJECT_TYPE             STATUS
U1_TBL_VW       VIEW                    INVALID
SQL>
Then you have to query DBA_DEPENDENCIES before dropping the user:
SQL> create user u1 identified by u1 default tablespace users quota unlimited on users;
User created.
SQL> create user u2 identified by u2 default tablespace users quota unlimited on users;
User created.
SQL> create table u1.tbl as select * from dual;
Table created.
SQL> grant select on u1.tbl to u2;
Grant succeeded.
SQL> create view u2.u1_tbl_vw as select * from u1.tbl;
View created.
SQL> column owner format a10
SQL> column name format a10
SQL> select owner,name,type from dba_dependencies where referenced_owner = 'U1';
OWNER      NAME       TYPE
U2         U1_TBL_VW  VIEW
SQL>
SY.

Similar Messages

  • Query to find the memory of database in oracle,sql

    Hi All,
    Please let me know the query to find the memory of database in oracle,sql.
    Thanks,
    sajith

    How do I find the overall database size?
    The biggest portion of a database's size comes from the datafiles. To find out how many megabytes are allocated to ALL datafiles:
    select sum(bytes)/1024/1024 "Meg" from dba_data_files;
    To get the size of all TEMP files:
    select nvl(sum(bytes),0)/1024/1024 "Meg" from dba_temp_files;
    To get the size of the on-line redo-logs:
    select sum(bytes)/1024/1024 "Meg" from sys.v_$log;
    Putting it all together into a single query:
    select a.data_size+b.temp_size+c.redo_size "total_size"
    from ( select sum(bytes) data_size
    from dba_data_files ) a,
    ( select nvl(sum(bytes),0) temp_size
    from dba_temp_files ) b,
    ( select sum(bytes) redo_size
    from sys.v_$log ) c;
    Another query ("Free space" reports data files free space):
    col "Database Size" format a20
    col "Free space" format a20
    select round(sum(used.bytes) / 1024 / 1024 ) || ' MB' "Database Size"
    , round(free.p / 1024 / 1024) || ' MB' "Free space"
    from (select bytes from v$datafile
    union all
    select bytes from v$tempfile
    union all
    select bytes from v$log) used
    , (select sum(bytes) as p from dba_free_space) free
    group by free.p
    This is what I use :P From http://www.orafaq.com/wiki/Oracle_database_FAQ#How_do_I_find_the_overall_database_size.3F

  • Query to find the user is having access to sql server DB

    Hi,
    Please help me in this.
    Query to find the whether the user is having access to sql server DB.
    Cheers,
    sajith

    TUBBY_ORCL?Select 1 from dual where 'ORACLE' = 'SQL SERVER';
    no rows selected
    Elapsed: 00:00:00.01

  • SQL Query to Find out User has what all resources provisioned !

    Hi Guys ,
    Does any one have a SQL query to find out what resources are provisioned to a particular user ?
    Thanks
    Suren

    Hi,
    Hope this will help you.
    SELECT distinct usr_login as "IdM User ID",
    usr_employeeID as "Employee ID",
    usr.USR_FIRST_NAME as "First Name",
    usr.USR_LAST_NAME as "Last Name",
    usr_status
    as "User Status",
    USR_EMP_TYPE as "Employee Type",
    obj.obj_name as "Application Resource",
    ost_status as "Application Resource Status",
    FROM ost,oiu,obj,usr,obi
    WHERE oiu.ost_key = ost.ost_key AND obj.obj_key = obi.obj_key AND oiu.usr_key = usr.usr_key
    AND ost_status in ('Provisioned','Revoked','Disabled', 'Provisioning')
    AND oiu.obi_key=obi.obi_key
    AND usr_EmployeeID like '11111'
    This query will provide all the resources to which the user is linked with and the resource status is in 'Provisioned','Revoked','Disabled', 'Provisioning' status for a particular employeed ID, I am not completely sure whether I have given the Employee ID column from USR table as correct or not. Verify once and query the DB

  • Query to find iStore Users

    Hi ,
    Can someone please give me a query to find the iStore users i.e. Guest, B2C and B2B users and any other type....
    I want the list of all users who can login to iStore and place orders.
    Thanks,
    Srikanth

    Hey,
    Please use the below query to find the iStore users.
    SELECT a.user_name
         ,a.description
         ,a.email_address
         ,b.responsibility_name
    FROM FND_USER a
    ,fnd_responsibility_tl b
         ,FND_USER_RESP_GROUPS_DIRECT c
    WHERE 1=1
    AND a.user_id=c.user_id
    AND b.responsibility_id=c.responsibility_id
    and b.responsibility_name like 'IBE_CUSTOMER'
    AND a.end_date IS NULL
    AND c.end_date IS NULL
    ORDER BY a.user_name
    Thanks
    Pradeep

  • Query to find the users

    i have created user call mastermap
    osod
    boundary
    i need to get only above users in my query not the default and sample schemas like scott,dbsmnp...etc
    select username ifrom dba_users ....lists everyuser
    please let me know if any query for above request
    thanks for help

    856483 wrote:
    i have created user call mastermap
    osod
    boundary
    i need to get only above users in my query not the default and sample schemas like scott,dbsmnp...etc
    select username ifrom dba_users ....lists everyuser
    please let me know if any query for above request
    thanks for help
    select username from dba_users where USERNAME IN('MASTERMAP','OSOD','BOUNDARY');

  • Query to find the user ID create date and locked date

    Hi,
    As title, below is my query, it seem that it will not work as my expectation, can someone help?
    SELECT T0.[USER_CODE], T0.[U_NAME], T0.[LOCKED], T0.[LstLogoutD] AS 'Last Logon Date' , T1.[CreateDate]  FROM OUSR T0  INNER JOIN AUSR T1 ON T0.USERID = T1.userSign WHERE T0.[LOCKED] = 'N' AND
          T1.logInstanc = 1
    Thanks

    Try this
    After the Mr. Nagarajan post
    SELECT
    T0.[USER_CODE], T0.[U_NAME], Case when Isnull((Select Min(T1.date) from usr5 T1 where T0.USER_Code = T1.usercode GROUP by T1.Usercode), 0) <> 0 then (Select Min(T1.date) from usr5 T1 where T0.USER_Code = T1.usercode GROUP by T1.Usercode) else T0.[updateDate] end 'Creation date', T0.[lastLogin], T0.[Locked] FROM [dbo].[OUSR] T0
    Regards,

  • Query to find all users under specific MO: Security Profile (per_security_profiles)

    Hi Folks,
    Could you please help me out to get list of users under the selected MO: Secuirty Profile.
    Requirement:
    I have a parameter in which i can select MO: Security profiles those are under responsibility level. So based upon this parameter i need to populate all organizations under selected MO Security Profile and in third parameter i need to fetch all users which are under selected MO: Security Profile.
    So please help me to sort out this problem.

    Pl do not post duplicates - How to Fetch organizations under specific MO: Security Profile
    Pl continue the discussion in your original thread

  • Query to know a user is a Database User or a Windows User

    Hi All,
    Can any one help me with the query to find out the given user name is a database user or a windows user in oracle 10g/11g?
    Thanks in advance
    MK.

    ManuK wrote:
    I think i may not express what i really need.
    I have a set of users in the database. Some are database users and some are external users.
    I'm a bit more confused. Do you mean with database users, the schema users, the owners of the tables?
    I was trying to find out can i take out external users using the query
    SELECT username FROM dba_users where password ='EXTERNAL';
    The PASSWORD column of DBA_USERS held in older releases a hashed value of the password of the/a database user.
    There is no such possibility of getting a distinction of users here.
    and database users using the query
    SELECT username FROM dba_users where password IS NULL;
    In the new releases this value is always NULL
    What you really need is what we described in earliers posts.
    Or you need to make clear by what you mean with WINDOWS USERS.
    Are this the USERS connecting from a WINDOWS CLIENT ( a PC/Notebook) to a database account in your database?
    Then look them up in V$SESSION ( OSUSER column )
    Or do you need to find the SCHEMA users that these WINDOWS users connnect to ( USERNAME column of V$SESSION )
    Regards,
    FJFranken

  • Query to find Memory used by each session in the database

    Hi All,
    Is there any query to find the memory utilised by each session in the database.I am in 9i database.
    Regards
    Vijay

    Memory using sessions script,
    SET LINESIZE 145
    SET PAGESIZE 9999
    COLUMN sid FORMAT 99999 HEADING 'SID'
    COLUMN serial_id FORMAT 999999 HEADING 'Serial#'
    COLUMN session_status FORMAT a9 HEADING 'Status' JUSTIFY right
    COLUMN oracle_username FORMAT a12 HEADING 'Oracle User' JUSTIFY right
    COLUMN os_username FORMAT a9 HEADING 'O/S User' JUSTIFY right
    COLUMN os_pid FORMAT 9999999 HEADING 'O/S PID' JUSTIFY right
    COLUMN session_program FORMAT a18 HEADING 'Session Program' TRUNC
    COLUMN session_machine FORMAT a8 HEADING 'Machine' JUSTIFY right TRUNC
    COLUMN session_pga_memory FORMAT 9,999,999,999 HEADING 'PGA Memory'
    COLUMN session_pga_memory_max FORMAT 9,999,999,999 HEADING 'PGA Memory Max'
    COLUMN session_uga_memory FORMAT 9,999,999,999 HEADING 'UGA Memory'
    COLUMN session_uga_memory_max FORMAT 9,999,999,999 HEADING 'UGA Memory MAX'
    prompt
    prompt ----------------------------------------------------
    prompt | User Sessions Ordered by Current PGA Size |
    prompt ----------------------------------------------------
    SELECT
    s.sid sid
    , s.serial# serial_id
    , lpad(s.status,9) session_status
    , lpad(s.username,12) oracle_username
    , lpad(s.osuser,9) os_username
    , lpad(p.spid,7) os_pid
    , s.program session_program
    , lpad(s.machine,8) session_machine
    , sstat1.value session_pga_memory
    , sstat2.value session_pga_memory_max
    , sstat3.value session_uga_memory
    , sstat4.value session_uga_memory_max
    FROM
    v$process p
    , v$session s
    , v$sesstat sstat1
    , v$sesstat sstat2
    , v$sesstat sstat3
    , v$sesstat sstat4
    , v$statname statname1
    , v$statname statname2
    , v$statname statname3
    , v$statname statname4
    WHERE
    p.addr (+) = s.paddr
    AND s.sid = sstat1.sid
    AND s.sid = sstat2.sid
    AND s.sid = sstat3.sid
    AND s.sid = sstat4.sid
    AND statname1.statistic# = sstat1.statistic#
    AND statname2.statistic# = sstat2.statistic#
    AND statname3.statistic# = sstat3.statistic#
    AND statname4.statistic# = sstat4.statistic#
    AND statname1.name = 'session pga memory'
    AND statname2.name = 'session pga memory max'
    AND statname3.name = 'session uga memory'
    AND statname4.name = 'session uga memory max'
    ORDER BY session_pga_memory DESC
    Thanks

  • Query to find out the time used by an user for an application

    Hello All,
    I want to know the query to find out the whole time used by the user for an application. Please view the below data
    Employee:
    SNO EMP_ID EMP_NAME EMP_DATE LOGIN_TIME LOGOUT_TIME
    1 10 Visu 21-Nov-2010 06:30:00 07:30:00
    2 10 Visu 21-Nov-2010 06:40:00 07:20:00
    3 10 Visu 21-Nov-2010 06:50:00 07:50:00
    4 10 Visu 21-Nov-2010 07:30:00 08:30:00
    5 10 Visu 21-Nov-2010 09:30:00 10:30:00
    By checking the above data we can say that the total time Visu used the application is
    8.30 - 6.30 (From 1,2,3,4 records) = 2hrs
    10.30 - 9.30 (Based on 5th rec) = 1hr
    So the total time Visu used the application would be 3 hrs = 180 mins.
    Could you please help me in getting the result from that data using a query?

    odie_63 wrote:
    I think it may be solved with analytics too.
    with t1 as (
                select 1 sno,10 emp_id,'Visu' emp_name,'21-Nov-2010' emp_date,'06:30:00' login_time,'07:30:00' logout_time from dual union all
                select 2,10,'Visu','21-Nov-2010','06:40:00','07:20:00' from dual union all
                select 3,10,'Visu','21-Nov-2010','06:50:00','07:50:00' from dual union all
                select 4,10,'Visu','21-Nov-2010','07:30:00','08:30:00' from dual union all
                select 5,10,'Visu','21-Nov-2010','09:30:00','10:30:00' from dual
         t2 as (
                select  emp_id,
                        emp_name,
                        emp_date,
                        to_date(emp_date || login_time,'DD-MON-YYYYHH24:MI:SS') login_time,
                        to_date(emp_date || logout_time,'DD-MON-YYYYHH24:MI:SS') logout_time
                  from  t1
         t3 as (
                select  t2.*,
                        case
                          when login_time < max(logout_time) over(
                                                                  partition by emp_id,emp_date
                                                                  order by login_time
                                                                  rows between unbounded preceding
                                                                           and 1 preceding
                            then 0
                          else 1
                        end start_of_group
                  from  t2
         t4 as (
                select  t3.*,
                        sum(start_of_group) over(partition by emp_id,emp_date order by login_time) grp
                  from  t3
         t5 as (
                select  emp_id,
                        emp_date,
                        min(login_time) login_time,
                        max(logout_time) logout_time
                  from  t4
                  group by emp_id,
                           emp_date,
                           grp
    select  emp_id,
            numtodsinterval(sum(logout_time - login_time),'day') time_spent
      from  t5
      group by emp_id
      order by emp_id
        EMP_ID TIME_SPENT
            10 +000000000 03:00:00.000000000
    SQL> SY.

  • Query to find the list of users having access to a particular scenario

    Hi,
    I am learning Hyperion Planning 9.2 x version. I wanted to know the query to find the list of users having access to Plan Iteration - 1 scenarion.
    As I am new to Hyperion Essbase and Hyperion Planning, I am assuming these ideas work out to get the desired result.
    1) As Hyperion Planning uses Relational DB to store the User Security information, we can query the list of users who is having access to Plan Iteration - 1 Scenario.
    I am not sure if this solution works. Please correct me If I am wrong.
    2) We can also query from the essbase editor to find out who all having access to this scenario.
    If the above is correct, can you please provide me the query.
    I am really need of this and I will be happy if any one provide the solution.
    Thanks & Regards,
    Upendra. Bestha

    Hi,
    If you are looking for some SQL to retrieve the access rights by member then you can use something like (SQL Server code though can easily be modified for Oracle)
    SELECT usr.object_name as Username,mem.object_name as Member,
    'Access Rights' = CASE acc.access_mode
    WHEN -1 THEN 'None'
    WHEN 1 THEN 'Read'
    WHEN 2 THEN 'Write'
    WHEN 3 THEN 'Write'
    ELSE 'Unknown' END,
    'Relation' = CASE acc.flags
    WHEN 0 THEN 'Member'
    WHEN 5 THEN 'Children'
    WHEN 6 THEN 'Children (inclusive)'
    WHEN 8 THEN 'Descendants'
    WHEN 9 THEN 'Descendants (inclusive)'
    ELSE 'Unknown' END
    FROM
    hsp_access_control acc, hsp_object mem, hsp_object usr
    WHERE acc.object_id = mem.object_id
    AND acc.user_id = usr.object_id
    AND mem.object_name = 'Plan Iteration - 1'
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Query to find out the list of user who have delete access

    Hi,
    I need a query to find out the list of users who have delete access on perticular folder/universe/ reports  in infoview.
    Please advice.
    Regards,
    Neo.

    orton607 wrote:
    thanks for replying guys. But the thing is i am using dynamic sql execute immediate in my package, so i want those tables also and the schema name.
    thanks,
    ortonThis is not possible. The best you could do is to have a good guess.
    Or how would you parse some dynamic statement as this:
       v_suffix := 'loyees';
       v_sql := 'Select count(*) from (select ''nonsense'' col1 from emp'||v_suffix||') where col1 = ''Y'''';
       execute_immediate(v_sql);
    ...What is the table name? How do you want to parse that?
    Better rewrite all dynamic SQL statements into non dynamic ones. Or do the source control logic for those dynamic parts in an extra module. For example implement your own dependency table and force every developer to add there all dynamic parts.

  • ORACLE E-BUSINESS SUITE 11i Query to find users who never logged in

    Dear, All -
    ORACLE E-BUSINESS SUITE 11i
    Is there a query to find out a list of users who were created but never logged into the system. I believe these users do no appear in FND_USER table since they never logged in.
    Thanks in advance!

    FAIRE wrote:
    Dear, All -
    ORACLE E-BUSINESS SUITE 11i
    Is there a query to find out a list of users who were created but never logged into the system. I believe these users do no appear in FND_USER table since they never logged in.
    Thanks in advance!All application users details are stored in FND_USER table (whether they logged in or not).
    To find the list of those users, please run this query:
    SQL> select *
    from FND_USER
    where LAST_LOGON_DATE is NULL
    and END_DATE is NULL;Thanks,
    Hussein

  • Find query technical name for a deleted query/workbook in the User Menu

    Hi,
    When a BEx workbook or BEx query is published in a role, people with that role will see the query / workbook in their user menu.
    It is possible to change the caption/title of the 'node' in the user menu so it does not necessarily have the same name as the report.
    I am now in a situation where a user tries to run a query/workbook from the user menu, and runs in an error message 'query does not exist on server'.
    How can I found out to which query/workbook a node in the user menu refers?
    I have tried the Metadata repository but because of the many nodes in the user menu this is a laborious task.
    I was hoping to find a table where I could use the role name and node name to find the 'target' report but I haven't been able to find such a table.
    Any (other) suggestions?
    Many thanks,
    Jan.

    Hi,
    You can publish the workbook to the role and as user have access to the role he can access the workbook also.
    Regards,
    Kams

Maybe you are looking for