I want to add one more SID for database? How to do it?
You can't. An Oracle database has a single SID. You can create multiple service names for a database. I'm not sure why you would want to have multiple SIDs but I suspect that whatever you want to do you can do by using service names.
Related
When connecting to Netezza via JDBC, the database in the URL is a required field - e.g. the value sales in the example URL jdbc:netezza://main:5490/sales;user=admin;password=password
The first time I connect to a Netezza instance, I don't (necessarily) know the name of a database on the appliance. Guessing a database name is a very time consuming exercise.
In this scenario, what value should I provide? Is there a "use default" option, a way to list databases, or a specific database name that will always work (e.g. a system database)?
Netezza will always have one main database: system.
You cannot delete the system database.
I would suggest that you connect to jdbc:netezza://hostname:5480/system.
Once connected, you can list the databases that your user has access to, using
select database
from _v_database;
I can't answer definitively, but it appears that every Netezza appliance by default has a database named TESTDB. This is at least true for all the appliances to which I have access.
Users or administrators may be able to delete this database, but it's a good bet if you need a database to which to connect.
English is not my native please understand
When I try to login like system/password as sysdba to oracle(linux) by sqldeveloper(window)
It fail when through Service Name and return ORA-0131 :insufficient privileges
but SID? successfully passed
what differences? and how to connect with Service Name?
Thomas Kyte explained the difference beatifully :
A service name is more flexible than a SID would be.
A database can dynamically register with a listener using one or more service names. In fact, more than one database can register with a listener using the same service name (think about a clustered environment where you have multiple instances that all are the same database under the covers).
A database on the other hand has a single SID. And a single SID goes to a single database. It is a pure 1:1 relationship.
A service is a many to many relationship.
Service names are used with dynamic registration - the data registers with the listener after it starts up. Once it does that, you can connect.
With the SID - that is more like telling the listener "I want you to connect to this specific database, I know the 'address', here you go"
With the SERVICE - you are asking the listener to put you in touch with a database that can service your request, a database that registers using that service.
More information here, https://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1508737000346067364
Similar question was asked in Stack Overflow 6 years back, How SID is different from Service name in Oracle tnsnames.ora
In your test environment, play around with tnsnames.ora and listener.ora. AFAIK, from 12c, Oracle uses only service_name, since it is flexible and has many to many relationship. I will cross-verify from documention if I find it incorrect.
I want to create a new database on an Oracle server via JDBC. I cannot seem to connect to the database without providing an SID: using a URL like jdbc:oracle:thin:#//[IP]:1521 results in an error of "ORA-12504, TNS:listener was not given the SID in CONNECT_DATA"
Alternatively, if I log into a specific SID, I can run most DDL commands except for CREATE DATABASE foo which fails with an error of "ORA-01100: database already mounted"
How am I supposed to create a database if I cannot connect to the server without specifying a specific database and cannot create a database if I am already logged into a specific database?
AFAIK creating a database needs an internal and direct connection which can only be done by logging in directly on the server (normally a user account called 'oracle').
One reason for that: users are stored in the database itself. No database = no user to connect to by an external client.
Please also note Justin's comment about oracles database schemas. This is probably what you are looking for
What you need are following commands:
CREATE TABLESPACE CREATE USER and few GRANT ... TO ... -- to have rights to connect and create objects, at least
I wanted to form oracle database URL for my JDBC conection and few websites say SID should be part of URL and few say schema name.
Please compare schema, service name and SID in ORACLE? And how they are related?
is it like SID:schema is 1:n as in one SID can point to n schemas?
Please explain with the relation between them.
A SID is the unique identifier for a database, or if it's a RAC system for an instance of a database.
A Service is an identifier for a service offered by the database, and the database should be configured for services such as "BILLING_APP" or "CUST_WEBSITE". http://docs.oracle.com/cd/B28359_01/server.111/b28320/initparams217.htm
Don't confuse a database and an instance, by the way. A database is the set of data and control (etc) files, the instance is the memory areas and processes that access it. RAC has multiple instances per database, each of which can register with the listener to offer all or a subset of the total services offered by the database.
A schema is effectively the username that owns the objects, and there can be multiple schemas in the database.
So an application should be referencing a SERVICE to connect to, through a listener on a certain host and port. The listener resolves this to a database (possibly one of many that register to offer that service). The connection is made to the database as a user who might or might not be the owner of the schema. Typically the connection is not made as the schema owner for security reasons -- in fact the best level of security is to connect as User_A, calling code in User_B's schema, whicxh references tables in other users' schemas.
A SID is a Service ID and refers to a single Oracle database instance
A service name is very like a SID but multiple SIDs can be referenced by one Service Name
E.g. in a Dataguard scenario, the primary instance might be SID_01 and ORA_SRV. SID_02 and SID_03 are running somewhere on the network and receiving and applying the log files. SID_01 fails and SID_02 is brought up (Mounted and Opened) and now exposes itself ont he network as ORA_SRV.
Similarly with RAC multiple SIDs make up a single Service.
A schema is in effect a user.
A JDBC connection will be in some form of "HOST:PORT:(SID or Service name)". You will have to connect to the DB and will do so with a username and password. The username will (almost always) connect you to a schema of that name. You can can reference objects in another schema with dotted notation in your sql, e.g. SCHEMA.OBJECT_NAME
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.