Oracle Basic Knowledge

Source: Internet
Author: User

First, the database name

What is a database name?
The database name is the identity of a database, just like a person's ID number. He uses parameter db_name to indicate that if a machine is loaded with multiple databases, then each database has a database name. After the database installation or creation is complete, the parameter db_name is written to the parameter file. The format is as follows:
DB_NAME=MYORCL ...
When you create a database, you should consider the name of the database, and after you create the database, the database name should not be modified, even if you want to modify it will be cumbersome. Because the database name is also written to the control file, the control file is stored in binary mode, and the user cannot modify the contents of the control file. Suppose the user modifies the database name in the parameter file, that is, modifies the value of the db_name. However, when Oracle starts, a ORA-01103 error is returned because the db_name in the parameter file is inconsistent with the database name in the control file, causing the database to fail to start.
  
the role of database names
The database name is required to install the database, create a new database, create a database control file, modify the data structure, and back up and restore the database.
There are many Oracle installation file directories associated with database names, such as: winnt:d:\oracle\product\10.1.0\oradata\db_name\. Unix:/home/app/oracle/product/10.1.0/oradata/db_name/... pfile:
Winnt:d:\oracle\product\10.1.0\admin\db_name\pfile\ini.ora Unix:
/home/app/oracle/product/10.1.0/admin/db_name/pfile/init$oracle_sid.ora


Trace file directory:

Winnt:/home/app/oracle/product/10.1.0/admin/db_name/bdump/... In addition, when creating data, the database name in the Careate DB command is also consistent with the value of the db_name parameter in the parameter file, or an error is generated.
Similarly, the statement that modifies the database structure alter the database and, of course, also indicate the name of the databases to be modified.
If the control file is corrupted or missing, the database will not load, and the control file must be recreated by starting the instance nomount and then creating the control file with the Create Controlfile command, which is also referred to as db_name.
There are also database names that need to be used when backing up or recovering a database. In short, the database name is important to understand exactly what it does.
Querying the current data name
Method One: select name from V$database;

Method two: Show parameter db Method Three: View the parameter file.
Modify Database name
The previous recommendation: the database name should be determined when the database is created, and the database name should not be modified, because modifying the database name is a relatively complex thing. Now, let's explain how to modify the database name after the data has been created. The steps are as follows:
1. Close the database.
2. Modify the value of the db_name parameter in the database parameter file to the new database name.
3. Launch the instance in Nomount mode and build the control file (refer to Oracle Documentation for command syntax for creating control files)

second, the database instance name

What is a DB instance name?

The database instance name is the identity used to contact the operating system, meaning the database instance name is used for interaction between the database and the operating system. The instance name is also written to the parameter file, which is instance_name, and the instance name is also written to the registry in the Winnt platform.
The database name and instance name can be the same or different.
In general, database names and instance names are a one-to-many relationship, but if you are in an Oracle Parallel server architecture (that is, Oracle real-time application clusters), the database name and instance name are a one-to-numerous relationship.

Querying the current DB instance name
Method One: Select instance_name from V$instance;

Method Two: Show parameter instance

method Three: query in the parameter file.    
DB instance name and oracle_sid 
Although both tables are Oracle instances, there is a difference between the two. Instance_name is an Oracle database parameter. ORACLE_SID is an environment variable for the operating system. Oracld_sid is used to interact with the operating system, that is, to access the instance name from the operating system's perspective and must pass ORACLE_SID. In the Winnt, Oracle_sid also needs to exist in the registry.  



  

Third, the database domain name

What is a database domain name?




query database domain name  
method one:select value from v$parameter where name =  ' Db_domain ';  

Method two: Show parameter domain method three: query in the parameter file.
Global database name
Global database name = database name + database domain name, as described above the global database name for the Fujian node is: Oradb.fj.jtyz

Iv. Database service Name

What is the database service name?
Starting with the Oracle9i version, a new parameter, the database service name, was introduced. The name of the parameter is service_name.

If the database has a domain name, the database service name is the global database name; otherwise, the database service name is the same as the database name.

Querying database service names
Method One: Select value from v$parameter where name = ' service_name '; Method two: Show parameter Service_Name method three: Query in the parameter file.
Database service name and network connection
From the Oracle network components that are oracle8i open, the database and the client connection host string use the database service name. Previously used is ORACLE_SID, which is the DB instance name

    • Summarize:
      1. Three configuration files are placed in the $oracle_home\network\admin directory.
      2. Sqlnet.ora determine the parsing method
      3. Listener.ora on Sid_name, commonly used for JDBC access, corresponding error code is 12505
      4. Tnsnames.ora on the service_name, usually for the Linux sqlplus client, the corresponding error code is 12514

    • Sqlnet.ora

A nsswitch.conf file that acts like Linux or other Unix, and this file determines how to find a connection string that appears in a connection (connect descriptor)
 
If Sqlnet.ora is like this,

NAMES. Directory_path= (Tnsnames,hostname)
When the client enters Sqlplus Sys/[email protected], the ORCL record is first found in the Tnsnames.ora file. If there is no corresponding record, try to treat ORCL as a hostname
There are other options in parentheses, such as LDAP, but hostname,ldap are usually not commonly used, and usually only tnsname can be set.


 

    • Tnsnames.ora

1. Provide tnsname to host name or IP

ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = 127.0.0.1) (PORT = 1521)) #对应的SOCKET信息
(Connect_data =
(SERVER = dedicated) #使用专用服务器模式去连接
(service_name = ORCL) #这里填入对应 service_name,
Can be through "sqlplus>show parameter service_name;" View
)
  
SALES =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.188.219) (PORT = 1521))
(Connect_data =
(SERVER = dedicated)
(service_name = sales)
)
)

2. With Tnsname.ora inside the service_name, you can use the following command to view:

Sql> Show parameter service_name;

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
Service_names string ORCL

3. Tnsnames.ora is set up for Oracle client access to the database, not for remote clients connecting to the Oracle server

Delete Tnsnames.ora
[Email protected] admin]$ RM Tnsnames.ora
Restart Oracle

The local client cannot access the database
[Email protected] ~]$ sqlplus Scott/[email protected]

Sql*plus:release 10.2.0.1.0-production on Tue Feb 16 17:32:41 2010

Copyright (c) 1982, 2005, Oracle. All rights reserved.

ERROR:
Ora-12154:tns:could not resolve the connect identifier specified
At the far end (another machine)
Connect to Oracle Database in Sqlplus mode, no problem
Connect orcle database through JDBC, no problem



Listener.ora
The listener process accepts a remote access request to the database
Listener.ora

     #SID_LIST_LISTENER defined, Defines the LISTENER process listener SID
sid_list_listener =
(sid_list =                               #可以监听多个SID, there is a SID table in

   (sid_desc =
       (GLOBAL _dbname = boway)          # Global_ DBName is not required unless you use hostname to do a database connection
       (oracle_home = E:\oracle\product\ 10.1.0\db_2)
       (sid_name = ORCL)
  )
)

#监听器定义, a single database can be To have more than one listener
LISTENER =
   (DESCRIPTION =
        (ADDRESS = ( PROTOCOL = TCP) (HOST = Boway) (PORT = 1521))
   )

The URL of the JDBC connection request corresponds to Listener.ora

Jdbc:oracle:thin:@192.168.3.98:1521:orcl

Unlock Account

ALTER USER username account UNLOCK;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.