ORA-00054 error when trying to delete table - sql

When I try this command on oracle sql-developer :
delete from my_table;
I get the following error :
ORA-00054: resource busy and acquire with NOWAIT specified
I haven't figured out how to solve this problem.

Someone or yourself(unintentionally) has a lock on the table.
Query the table V$LOCKED_OBJECTS to find the name of the user (you would want OS_USER_NAME) locking it.
You can ask the user to unlock the table. They will have to either commit/rollback their transaction. If they are unable to do so and permit you to kill their session, you can use the below:
alter system kill session 'sid, serial#'
to kill their session which has a lock on your table where 'sid' & 'serial#' is something you have to find by querying v$session,v$sqlarea tables.
This can also be done in SQL developer, you can find out the session (if your user has access to meta tables) from the menu Tools --> Monitor Sessions
Right click on the correct session record (very important) and select mark for kill. You should be able to delete the records once the session is killed.

Check with database admin. They can check if anything is going on with the table. May be someone is performing something on the table in different session. Admin can kill the session. Then, you will be able to delete/truncate the table.

Related

ORA-14450: attempt to access the transactional temp table already in use

Folks, I'm with this error:
ORA-14450: attempt to access the transactional temp table already in
use.
Can someone help me?
The session which locks the table is not committed/roll backed the changes.
Find out which session blocks that table and kill that session. or wait till that session commit/rollback the changes.

How to unlock table in sybase?

im trying to change some types on my table in sybase, but when i change it, the output is this one.
User 'DBA' has the row in 'table' locked
How to unlock this?
I would:
determine the connection_id using sa_locks (documentation here)
issue the drop connection *connection_id* statement to the connection that is causing the lock to the table.
Use it with care!

Auditing logged in user with delete trigger

We have an audit option in our application, where we are auditing the deleted records from a table using AFTER DELETE ON trigger.
Problem description :
The problem that we face here is, we need to log the person who has deleted the record. We could not get id of the person deleted the record anywhere from the database as its not present. Its coming from the web application. My question is there anyway to get the name or id of the person who has logged into the web application in the database side.
We are using oracle 11g.
You should be able to do this using dbms_session package.Using the package you can set and get values.Hence , during the login to your application , you can set the value and finally while on delete trigger execution , get this and insert into the audit table.
This might come handy - http://www.dba-oracle.com/t_dbms_session.htm
Hope that helps !

Teradata locks - How to know if a table is locked?

Is there a way to know if a table is locked and what kind of lock is currently on a table? I was hoping for something through the DBC tables in teradata, but I can't find any reference to anything like this. I have normal user access and the DBA is no help. Thanks.
AFAIK only DBA utilities are available to determine the type of lock on a table.
With only user-level rights you can do something like the following (from here):
Lock Table dbName.myTable for Access nowait
Select * from dbName.myTable;
And according to the master himself (Geoffrey Rommel):
If the table is locked, you will get
error 7423, "Object already locked and
NOWAIT. Transaction Aborted."

PostgreSQL - Rename database

I need to rename the database but when I do in
PGAdmin : ALTER DATABASE "databaseName" RENAME TO "databaseNameOld" it told me that it cannot.
How can I do it?
(Version 8.3 on WindowsXP)
Update
The first error message : Cannot because I was connect to it. So I selected an other database and did the queries.
I get a second error message telling me that it has come user connect. I see in the PGAdmin screen that it has many PID but they are inactive... I do not see how to kill them.
Try not quoting the database name:
ALTER DATABASE people RENAME TO customers;
Also ensure that there are no other clients connected to the database at the time. Lastly, try posting the error message it returns so we can get a bit more information.
For future reference, you should be able to:
-- disconnect from the database to be renamed
\c postgres
-- force disconnect all other clients from the database to be renamed
SELECT pg_terminate_backend( pid )
FROM pg_stat_activity
WHERE pid <> pg_backend_pid( )
AND datname = 'name of database';
-- rename the database (it should now have zero clients)
ALTER DATABASE "name of database" RENAME TO "new name of database";
Note that table pg_stat_activity column pid was named as procpid in versions prior to 9.2. So if your PostgreSQL version is lower than 9.2, use procpid instead of pid.
I just ran into this and below is what worked:
1) pgAdmin is one of the sessions. Use psql instead.
2) Stop the pgBouncer and/or scheduler services on Windows as these also create sessions
Unexist told me in comment to restart the database and it works! Restarting the database kill all existing connection and then I connect to an other database and was able to rename it with my initial query.
Thx all.
Instead of deploying a nuke (restarting the server) you should try to close those connections that bother you either by finding where are they from and shutting down the client processes or by using the pg_cancel_backend() function.
When connected via pgadmin, the default database will be postgres.
ALTER DATABASE postgres RENAME TO pgnew;
This will not work.
You need to right click on server in pgadmin and set Maintenance DB to some other DB and save. Then retry and it should work if no other connections exists.
For anyone running into this issue using DBeaver and getting an error message like this:
ERROR: database "my_stubborn_db" is being accessed by other users
Detail: There is 1 other session using the database.
Disconnect your current connection, and reconnect to the same server with a connection that doesn't target the database you are renaming.
Changing the active database is not enough.
ALTER DATABASE old_database RENAME TO new_database;
old_database means already existing database.
new_database means need to modify this name.
Example: ALTER DATABASE profile RENAME TO address;