简体   繁体   中英

How to specify schema while DB connection in typeORM for oracle DB

I am a beginner with TypeORM, I am using oracle DB with node js in the backend. I have managed to connect the db with typeORM using createConnection() . But I am not able to specify the schema while creating connection

Another way is adding schema to each entity like this

@Entity({schema:"Users"})

But I cant use this as the schema will be changing according to the dev/test/prod environment. Only way can be specifying it during creating connection

I checked typeORM connection options documentation https://github.com/typeorm/typeorm/blob/master/docs/connection-options.md It has schema option for postgres and MySQL but it doesn't specify any options for oracle.

In Oracle, "user" and "schema" are effectively the same thing. In most cases (unless you are a DBA or have other specific elevated privileges) you must connect directly to the user/schema you want to work with. There is no way to change user/schema once your connection is established; you would have to reconnect with new credentials.

If you do have elevated privileges to work with objects in schemas other than the one you connected to (eg create any table ), you can do that by fully qualifying the object name (eg schema_name.table_name ) in your DDL, DML, or SQL. You would not need to reconnect first.

In cases where there is a shared application schema/user, proxy user access can be configured by the DBA that will allow you to connect as another user using your personal credentials and avoid having to share common passwords or keys, but you would still be connected to a specific schema/user.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM