Liquibase oracle multiple schemas with different credentials - oracle

How to redefine liquibase.properties files for different changesets if there are several users (schemas) in the oracle database with privileges only for their schema?

Looking at the release notes for SQLcl 21.4 (current latest version), they state
In this release, you can only capture objects from the schema you are connected to in SQLcl.
So if you are using SQLcl and need to generate changes from multiple schemas, you will need to connect to each schema and generate the changes individually.

When I have such projects as the one you described - with multiple schemas, I prefer to create a special user (schema) with privileges to other schemas and use this user in liquibase.properties file.
Basically, the easiest way is to create a specific role with grants to other schemas.

Related

In Oracle, how do I determine what audit settings are present for individual schemas?

I manage an Oracle database as DBA in my current role, but the database infrastructure including audit settings was defined by my predecessor, who I cannot contact.
I am trying to identify how my predecessor set up Oracle auditing. I suspect they configured auditing at a schema level with different configurations for different schemas. Is this possible?
If so, how do I see the different configurations for each schema?
Thanks

Cloning a Oracle Database Schema

I have an Oracle 12c Instance with a scheme 'wadmin' user, this instance has tables, view, data, triggers, sequences etc.
For quick spinning of docker images, I need to clone the db schema as fast as possible , so that I can create another user 'wadmin1' link it to new docker and start my testing.
Any CLI/tools for the same, does oracle provide any options?
I do not know if this is exacly what you are looking for but you can export your Oracle schema using ORACLE DataPump tool. This involves storing exported schema in the Oracle directory. While exporting schema to file you can transform the schema name, omit unnecessary tables or data etc. Exported files with database schema can be later used for imported to new database instance. More information regarding Oracle DataPump you can find here. https://oracle-base.com/articles/10g/oracle-data-pump-10g#SchemaExpImp.
Alternatively you can have scripts that create the database stored in the Git repository and integrate your builds with too called Flyway https://flywaydb.org/ which can be used to automatize of database schema creation. This is also really convenient from source control point of view. All changes on the schema are pull requested.
In my team we use OracleDataPump when we want to recreate the database together with the data, Flyway is used as a part of our continues integration.

How can I set a JBOSS data source to an Oracle database use a different schema to the one used for authentication

I have a Java webapp (WAR) that is to be run in JBOSS.
That webapp is to create connections to an Oracle database using a username/password for a user that is given read-only permissions.
The webapp queries tables belonging to a different schema. I do this by qualifying each table name in my SQL queries.
However, I would like to parameterise this in my datasource, since the schema names can be different in different environments.
Is there a way to define a JBOSS data source which logs in as User A for each connection, but uses Schema B for all queries?
One way to do it is to use the new-connection-sql or check-valid-connection-sql datasource properties to execute ALTER SESSION SET CURRENT_SCHEMA=yourschema, which will change the default schema for each connection.
Recommended way is to create synonyms in Oracle for your User A to access tables in schema owned by User B. This way you can even grant specific privileges to user A to select, update, insert on tables owned by the other UserB.

Documentum multiple repositories in single database

Is there a way to accommodate multiple copies of the Documentum repository in a single database? I was thinking of setting up multiple database schemas to facilitate this and then export/import as needed from one schema to another.
Thanks!
You typically would have different docbase names and ids for each environment. If you have that then you can also use different users as repository owner and have no conflict at the database level because each user can have it's own schema.
If you use the same docbase name/id in all environments then users must match and you cannot use the same database.
Also, export/importing at the db level is dangerous and skips steps done by the repository like updating sequences, creating tables, etc.

Change Oracle Schema at runtime when using SubSonic

In my project, I am using Oracle Database and SubSonic for DAL. I have a problem with SubSonic and Oracle Schema, that is:
When developing, I used a schema DEV in Oracle Database and generate DAL using SubSonic.
After that when release to customer, he used a new schema TEST in Oracle Database and changed the connection string in app.config to connect to Oracle. The error will appear, that is “Table or View does not exist”. I found this error and see that the schema of tables is still DEV.
I do not want re-generate DAL after change schema and when released to the customer. Please help me.
Firstly, your schema should not be DEV. DEV is a user or role.
Your schema name should be related to the data content (eg ACCOUNTS or SALES)
Secondly, consider whether you or the customer is going to decide the schema name. Say you have a product called FLINTSTONE. You may decide that the schema name should be FLINTSTONE. However your customer may want to run two instances of your product (eg one for local sales, the other for international) and use the same database. So they want FS_LOCAL and FS_INTER as the schema names. Is that option a feature of your product ?
Next, decide if your application should connect as the schema owner. There are good security reasons for NOT doing that. For example, the schema owner has privileges to drop tables, which is generally something the application doesn't do and thus, on the principle of least privilege, is something your application shouldn't have privileges to do.
Generally I would recommend some config parameter for the application for the schema name, and after connecting to the database, the app should do an "ALTER SESSION SET CURRENT_SCHEMA = 'whatever was it the config file'". The application database user would need the appropriate insert/update/delete/select/execute privileges on the objects in the application schema. If the application can't do that, you can have a LOGON trigger in the database.
Gary is correct in not using DEV as a schema on your own machine. In using Oracle we typically set up the schema as what the client is going to name their schema. This however does not fix your issue. What you need to do is create a global alias in Oracle that maps say DEV to CLIENTSCHEMA. You should still rename the schema on your machine but this will allow your schema to differ from your clients.

Resources