更改Global_name, domain_name, db_name 的方法

studywell發表於2014-10-10

更改Global_name, domain_name, db_name 的方法

參考P894<>

 

In a distributed database system, each database should have a unique global database name. Global database names uniquely identify a database in the system.

A global database name is formed from two components: a database name and a domain. The database name and the domain name are determined by the following initialization parameters at database creation:

Database name                                  db_name

Domain containing the database           db_domain

 

The DB_DOMAIN initialization parameter is only important at database creation time when it is used, together with the DB_NAME parameter, to form. the database’s global name. At this point, the database’s global name is stored in the data dictionary. You must change the global name using an ALTER DATABASE statement, not by altering the DB_DOMAIN parameter in the initialization parameter file. It is good practice, however, to change the DB_DOMAIN parameter to reflect the change in the domain name before the next database startup.

 

Use the ALTER DATABASE statement to change the domain in a database’s global name. Note that after the database is created, changing the initialization parameter DB_DOMAIN has no effect on the global database name or on the resolution of database link names.

 

如果你要DBLink後面使用域名mydomain,方法是:

UPDATE GLOBAL_NAME SET GLOBAL_NAME = dbname.mydomain;

(這個其實是操作Global_NAME這張表)

SQL> desc global_name;

 Name                                      Null?    Type

 ----------------------------------------- -------- ----------------------------

 GLOBAL_NAME                                     VARCHAR2(4000)

 

Alter database rename global_name to dbname.mydomain;

這個又是如何實現的呢?是更改的哪個資料字典還是什麼?

 

去掉DBLink後面的DOMAIN名字的方法

 

如果你要DBLink後面不使用域名,方法是:

update global_name set global_name='hq';

1 row updated.

 

SQL> commit;

 

Commit complete.

 

但這時卻不能使用:

ALTER DATABASE RENAME GLOBAL_NAME TO hq’; 來實現,這時為什麼呢?

 

這樣看來alter database rename global_name to ***.***.***;

Update global_name set global_name = '***.***.***';

並不是等價的操作。兩者間的區別是什麼呢?

 

設定完畢後,看結果是否改變:

SELECT GLOBAL_NAME FROM GLOBAL_NAME;

 

如果alter database rename global_name to 中的name沒有指定域名,則預設為先前global_name中包含的域名.

 

所有這些操作都是透過更新資料字典Global_name 來實現的,都不會更新引數檔案裡Global_name, db_domain 的內容。

 

總結:   

1 在資料庫建立的時候,global_name db_domain,db_name組成。

2 當資料庫建立完後,對global_name的更改只能透過Alter database rename  statement update global_name set global_name 語句來做。且這個結果不會反映回到引數檔案中,是儲存在資料字典中的。

3 當資料庫建立完後,對引數檔案中db_main的修改不會影響資料庫的Global_name.

 

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29519108/viewspace-1294347/,如需轉載,請註明出處,否則將追究法律責任。

相關文章