Useful shortcuts for vi editor

Friday 18 May 2018

"database "example" is being accessed by other users" solution

Action
postgres=# drop database example;

Error
ERROR:  database "example" is being accessed by other users
DETAIL:  There is 1 other session using the database.

Solution
Run following sql code;

postgres=# 
SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = 'example' AND pid <> pg_backend_pid();

All sessions should be terminated where belong to "example" database except backend sessions.

Lastly, try to drop it again.

Sunday 6 May 2018

How to backup database in XE?

It is very simple to backup your database in Oracle XE with already prepared .bat file quickly.

Steps;
Press Windows Key -> Type "Backup Database" -> Click "Backup Database" link -> .bat file "Backup.bat" runs -> Follow the steps -> Done

Finally, check the backup path;
...\oracle\fast_recovery_area\XE