SQL Developer 18.3: set alternative schema for individual connections automatically - oracle-sqldeveloper

I'm using several connections in SQL developer to connect to different Oracle databases. For some connections I have to change the schema to that of another user. This can be done is several ways
By using: alter session set current_schema = <otheruser>;
The drawback is that I have to enter this for every connection I want to open and with a different <otheruser> for each connection.
Using the global connection startup script in Preferences > Database > Filename for connection startup script. The drawback of this method is that SQL Developer uses the same global startup script and runs it for every connection I open. Probably trying to set a non existing schema in most -but one- connections.
Is there a way to automatically set the default schema on connecting to a database for individual connections?
Connection Schema
conn_1 Leave current schema unchanged for this connection
conn_2 Change current schema to <schema_A> for this connection
conn_3 Leave current schema unchanged for this connection
conn_4 Change current schema to <schema_B> for this connection
conn_5 Change current schema to <schema_C> for this connection
A solution will be very helpful.

No, that is not a feature. We assume when you define the connection, you are using the schema that you want to work with.
The tool is VERY connection driven - using alter session set current schema will work with queries you run in a SQL Worksheet, but won't have any effect for the rest of the tool, say browsing your tables in the Connection navigation tree.
Now, if you have PROXY connect privs, you could set up your connection to actually connect to your 'default' schema via proxy.
I show how here

Related

Creating a connection in SQLDeveloper

I am new to Oracle databases(I am using Oracle Database 11g Express Edition) and sqldeveloper. I have this doubt
When creating a new connection in sqldeveloper what is actually happening?
Creating a new database or connecting to an existing databasE?
If I create multiple connections are they pointing to a single database or different databases, if the later then how to choose a database name while creating a connection
You are establishing a connection to user (i.e. schema) which resides in an (Oracle) database. One database contains many users, so - create one connection per user.
Creating a connection does NOT create a new database; it is done differently. I don't think that 11gXE offers that option; you'd need a Standard or Enterprise Edition.
No problem if you use multiple databases (most of us do). I prefer keeping them in TNSNAMES.ORA file, in a directory used by the TNS_ADMIN environment variable. Currently, there are 94 databases I have access to, each of them having many users.
In your case, 11gXE is (probably) installed on your own computer, and you'll use one of its users (HR?), so - just connect to it. If it is locked, you'll have to unlock it first, though - in that case, create connection to SYS (don't forget to connect AS SYSDBA), then
ALTER USER hr ACCOUNT UNLOCK;
ALTER USER hr IDENTIFIED BY hr;
and then create connection to "hr" whose password is now set to "hr" (all lower case).

Is it possible to edit firebird database, alter trigger without connecting to it?

Is it possible to edit firebird database, alter trigger without connecting to it, using raw .fdb file or .gbak?
Although with sufficient knowledge of the internal structure of Firebird it would be possible to edit the file directly, in practice that is not a viable way (and would be a great way to corrupt your database).
Users with admin rights can disable firing database triggers on connect for a connection, see also Database Triggers.
For example when you use ISQL, you can start it with isql -nodbtriggers. This only works with SYSDBA, or if you have the RDB$ADMIN role and if you specify that role on connect.

How to backup a DB2 database OFFLINE while it is in use

Assume there is an application in a non-stop loop trying to read from database.
I have tried the following but it does not work:
db2 CONNECT TO SAMPLE
db2 QUIESCE DATABASE IMMEDIATE FORCE CONNECTIONS
db2 TERMINATE
db2 DEACTIVATE DB SAMPLE
db2 BACKUP DATABASE SAMPLE
It seems as if (DEACTIVATE DB) does not do anything since an application in a loop can still read from the database.
I keep getting the error "The database is currently in use" when trying to backup.
You have to make sure there are not applications connected to the database (db2 list applications). Also, you have to make sure the database is not active (db2 list active databases).
Remember that a quiesce or a force applications, is a asynchronous task. It means that you execute any of them, but when the control is returned it does not mean the applications have bee disconnected.
A typical case is a rollback of a batch process, when the rollback takes several minutes.
QUIESCE DATABASE will not prevent new connections from coming in. I believe you have at least two choices:
Use QUIESCE INSTANCE <instance> USER <username> RESTRICTED ACCESS IMMEDIATE FORCE CONNECTIONS. This will force all existing connections and restricts access for new connections. Only the user specified in USER will be able to connect. Presumably, this will be your administrative account.
If this is a no-go, or if you are unable prevent USER from spawning new connections, you may want to (temporarily) UNCATALOG DB and/or disable the DB2COMM registry variable in order to prevent new connections.
HTH.

Informix dbserver connections in sqlhosts via perl

I want to add a new Informix sever entry into sqlhosts, but I'm not quite sure how it will impact the existing connection.
Currently sqlhosts contains only one server entry...
dbserver onsoctcp 111.111.111.20 7101
The database handle is created within an existing perl module (db is a database on the server)...
my $dsn = "DBI:Informix:db";
my $dbh = DBI->connect($dsn,"user","password");
Notice that "dbserver" is never referenced.
I want to add a test server to sqlhosts. Something like this...
dbserver onsoctcp 111.111.111.20 7101
dbserver_test onsoctcp 111.111.111.21 7101
With only one entry in sqlhosts, everything has been working fine. But my connection never references the server name in sqlhosts.
So, my question(s)...
Does Informix just try to use the only one available?
Will adding a second server entry in sqlhosts force me to include the server name in the connection string?
Thanks!
Informix client uses environment variables to resolve hosts and other configuration; check that INFORMIXDIR is set to the path where Informix CSDK is installed (I assume it is), and set INFORMIXSERVER to point to the new entry in sqlhosts. See this article in IBM knowledge base.
Alternatively, use db#server data source format:
my $dbh = DBI->connect("DBI:Informix:db#server", "user", "password");
Maybe it is a permissions issue? From the documentation:
Note that you might also be able to connect to other databases not
listed by DBI->data_sources using other notations to identify the
database. For example, you can connect to "dbase#server" if "server"
appears in the sqlhosts file and the database "dbase" exists on the
server and the server is up and you have permission to use both the
server and the database on the server and so on. Also, you might not
be able to connect to every one of the databases listed if you have
not been given at least connect permission on the database. However,
the databases listed by the DBI->data_sources method certainly exist,
and it is legitimate to try connecting to those sources.
http://search.cpan.org/~johnl/DBD-Informix-2013.0521/Informix.pm

How to set connection timeout value for pgAdmin?

I am using pgAdmin to connect remotely to my database as phpPgAdmin is a bit limited in its features. Only problem is if I leave the SQL window open without running a query for a few minutes, then it says I need to reconnect.
Is this a setting I need to change in my database to keep remote connections alive for longer or is it a pgAdmin setting?
It is client setting.
You need specify connect_timeout in your config file.
29.1. Database Connection Control Functions
29.14. The Connection Service File