kill my session without administrative privelage? - session

I have accidently executed a procedure and i want o kill the session.
I have tried almost all the options i can search so far for granting access and killing sessions. but each time a SQL Error: ORA-01031: insufficient privileges error is displayed.
Just want to know if there is any possible way I can kill this session.
PS: I am working on a Development environment.

Related

Configure Oracle XE logging running on Windows 10, prevent writing to Windows Event Log

Environment:
Oracle XE 18 running on Windows 10 (my laptop!).
I run database commands using specific users and sys.
Problem:
The windows application event log has 1000's of verbose Oracle database logging, for example every SELECT statement, indeed every command I run!
Launch Windows Event Viewer, execute at command prompt: eventvwr
Questions:
How to configure Oracle so that only certain messages are written
the to the Windows Event Log. Ideally no commands that I execute are
logged.
Does Oracle XE also write to log files (not windows event logs) and if so how to configure the granularity?
(I'm fairly new to Oracle)
Additional Info:
Below is an example of a windows application event log
Looking at your screenshot, it seems you are using the SYS user to execute your SQL commands. By default, all operations executed by users using SYSASM, SYSBACKUP, SYSDBA, SYSDG, SYSKM, or SYSOPER privileges are audited and go to the event log. You can disable that behavior with the AUDIT_SYS_OPERATIONS initialization parameter.
See documentation here: https://docs.oracle.com/en/database/oracle/oracle-database/19/refrn/AUDIT_SYS_OPERATIONS.html#GUID-58176267-238C-40B5-B1F2-BB8BB9518950
When logged in as SYS, you can change the parameter setting with the following command:
alter system set audit_sys_operations=false scope=spfile;
Then restart the database.
That said, in general you should not be using SYS for day-to-day operations and preferably would leave the default auditing in place. Instead, use a user account with normal privileges (i.e. not SYS as SYSDBA) to do everything that doesn't require those elevated privileges. For the most part you wouldn't need that level of access except for startup/shutdown, backup operations, and installing patches.
create user myuser identified by mypassword;
grant dba to myuser;
alter user myuser default role all;
That should give you a user with plenty of elevated privileges that won't constantly trip the built-in auditing.
Read up on Oracle security here: https://docs.oracle.com/en/database/oracle/oracle-database/18/dbseg/introduction-to-oracle-database-security.html#GUID-41040F53-D7A6-48FA-A92A-0C23118BC8A0

dbms_utility.exec_ddl_statement doesn't work

I want to kill session over dblink however dbms_utility.exec_ddl_statement doesn't work.
Below command doesn't throw any error but also it doesn't kill the session.
exec dbms_utility.exec_ddl_statement#dblink('Alter system kill session ''274,12303,#1'' immediate');
It appears that you want to kill session which resides in a remote database. If that's so,
create a procedure in that (remote) database
it would kill session
one option is to use dynamic SQL to do that (i.e. execute immediate)
which one? The one whose parameters will be passed as procedure's arguments
call the procedure over the database link
I assume that the session with sid=274, serial=12303 on node=1 is running a heavy DML/DDL statement, and that by saying "it doesn't kill session" you mean that the session is seen as ACTIVE in GV$SESSION after the command is run.
That is an expected behavior. As counter-intuitive as it may be, KILL SESSION doesn't really "kill" session - it sends a kill signal which the session will respect after it's current work is done. Not before. So not an option for the assumed scenario.
Two other options:
ALTER SYSTEM DISCONNECT SESSION '274,12303,#1' IMMEDIATE
kill OS process.
ORACLE-BASE article
P.S. dbms_utility.exec_ddl_statement#dblink(q'!Alter system kill session '274,12303,#1' immediate!'); alternative quoting mechanism. No more double-ticks since 10g.

Killing active and inactive sessions in oracledb

I am trying to execute stored procedure package changes from sql developer console and oracle session hangs. For now I am killing the oracledb and launching it again
I checked stackoverflow regarding the issue and came across a similar question How to kill all active and inactive oracle sessions for user which suggests the following queries to kill hanging sessions
SELECT sid, serial#, status FROM v$session;
ALTER SYSTEM KILL SESSION 'sid,serial#' IMMEDIATE;
But on executing them I get
"table or view does not exist"
Can someone help me with queries to fetch all sessions and killing hanging sessions in oracledb ?

How to terminate Oracle procedures which is running

I created an oracle procedure. When i execute it from sqldevoloper in some case i think it is going into an infinite loop. It keeps on generating the log files. How can i terminate this running procedure?
I stopped the oracle service through services.msc . When i start it again , log files are getting generated. I think still that procedure is running.
How can i terminate those procedures.
Identify your session (hung) from v$session using
select sid, serial#, status from v$session where USERNAME='NAME';
And then kill it using
ALTER SYSTEM KILL SESSION 'SID,#SERIAL';
ALTER SYSTEM KILL SESSION
But you have to retrieve session id and have rights.

Oracle ALTER DATABASE OPEN

Im having some trouble with an oracle database. Every time i try to connect, i get this message.
ORA-01033: ORACLE initialization or
shutdown in progress
I searched the web, and found that the solution is to execute an alter database open command, but what I dont understand is where should i execute if, since I cant connect to the database.
Am I missing something?
Thanks in advance
You should connect AS SYSDBA:
sqlplus "sys/pwd AS SYSDBA"
An ORA-01033 would also be thrown if the connection attempt were made against a mounted standby database (Oracle Data Guard environment) by a non-sysdba user. Maybe a database role change (switchover or failover) has occurred since your last connection attempt.
Which OS are you using? The database is still shutting down - check the alert log as to the status of where it is at. Sometimes there are sessions hanging around that need to manually be killed off, there should be an indication of this in the alert log. It also depends how the database was shutdown, NORMAL, TRANSACTIONAL, IMMEDIATE. Even with a SHUTDOWN IMMEDIATE the sessions hanging around may still happen. To find the sessions on UNIX use the 'ps' to list all processes on the server ('ps -eaf' on Solaris) command and 'grep' for the ORACLE_SID name.

Resources