Oracle中的global_name和db domain

來源:互聯網
上載者:User

Oracle中的global_name和db domain

  1. 1. You connect to SALES.US.EXAMPLE.COM and query the GLOBAL_NAME data dictionary view to determine the current database global name:

  2. CONNECT SYSTEM@sales.us.example.com
  3. SELECT * FROM GLOBAL_NAME;

  4. GLOBAL_NAME
  5. ----------------------------------------------------------------------------
  6. SALES.US.EXAMPLE.COM

  7. 2. You query the V$PARAMETER view to determine the current setting for the DB_DOMAIN initialization parameter:

  8. SELECT NAME, VALUE FROM V$PARAMETER WHERE NAME = 'db_domain';

  9. NAME VALUE
  10. --------- -----------
  11. db_domain US.EXAMPLE.COM

  12. 3. You then create a database link to a database called hq, using only a partially-specified global name:

  13. CREATE DATABASE LINK hq USING 'sales';

  14. The database expands the global database name for this link by appending the domain part of the global database name of the local database to the name of the database specified in the link.

  15. 4. You query USER_DB_LINKS to determine which domain name the database uses to resolve the partially specified global database name:

  16. SELECT DB_LINK FROM USER_DB_LINKS;

  17. DB_LINK
  18. ------------------
  19. HQ.US.EXAMPLE.COM

  20. This result indicates that the domain part of the global database name of the local database is us.example.com. The database uses this domain in resolving partial database link names when the database link is created.

  21. 5. Because you have received word that the sales database will move to Japan, you rename the sales database to sales.jp.example.com:

  22. ALTER DATABASE RENAME GLOBAL_NAME TO sales.jp.example.com;
  23. SELECT * FROM GLOBAL_NAME;

  24. GLOBAL_NAME
  25. ----------------------------------------------------------------------------
  26. SALES.JP.EXAMPLE.COM

  27. 6. You query V$PARAMETER again and discover that the value of DB_DOMAIN is not changed, although you renamed the domain part of the global database name:

  28. SELECT NAME, VALUE FROM V$PARAMETER
  29.   WHERE NAME = 'db_domain';

  30. NAME VALUE
  31. --------- -----------
  32. db_domain US.EXAMPLE.COM

  33. This result indicates that the value of the DB_DOMAIN initialization parameter is independent of the ALTER DATABASE RENAME GLOBAL_NAME statement. The ALTER DATABASE statement determines the domain of the global database name, not the DB_DOMAIN initialization parameter (although it is good practice to alter DB_DOMAIN to reflect the new domain name).

  34. 7. You create another database link to database supply, and then query USER_DB_LINKS to see how the database resolves the domain part of the global database name of supply:

  35. CREATE DATABASE LINK supply USING 'supply';
  36. SELECT DB_LINK FROM USER_DB_LINKS;

  37. DB_LINK
  38. ------------------
  39. HQ.US.EXAMPLE.COM
  40. SUPPLY.JP.EXAMPLE.COM

  41. This result indicates that the database resolves the partially specified link name by using the domain jp.example.com. This domain is used when the link is created because it is the domain part of the global database name of the local database. The database does not use the DB_DOMAIN initialization parameter setting when resolving the partial link name.

  42. 8. You then receive word that your previous information was faulty: sales will be in the ASIA.JP.EXAMPLE.COM domain, not the JP.EXAMPLE.COM domain. Consequently, you rename the global database name as follows:

  43. ALTER DATABASE RENAME GLOBAL_NAME TO sales.asia.jp.example.com;
  44. SELECT * FROM GLOBAL_NAME;

  45. GLOBAL_NAME
  46. ----------------------------------------------------------------------------
  47. SALES.ASIA.JP.EXAMPLE.COM

  48. You query V$PARAMETER to again check the setting for the parameter DB_DOMAIN:

  49. SELECT NAME, VALUE FROM V$PARAMETER
  50.   WHERE NAME = 'db_domain';

  51. NAME VALUE
  52. ---------- -----------
  53. db_domain US.EXAMPLE.COM

  54. The result indicates that the domain setting in the parameter file is the same as it was before you issued either of the ALTER DATABASE RENAME statements.

  55. 9. Finally, you create a link to the warehouse database and again query USER_DB_LINKS to determine how the database resolves the partially-specified global name:

  56. CREATE DATABASE LINK warehouse USING 'warehouse';
  57. SELECT DB_LINK FROM USER_DB_LINKS;

  58. DB_LINK
  59. ------------------
  60. HQ.US.EXAMPLE.COM
  61. SUPPLY.JP.EXAMPLE.COM
  62. WAREHOUSE.ASIA.JP.EXAMPLE.COM

  63. Again, you see that the database uses the domain part of the global database name of the local database to expand the partial link name during link creation.

由此說明, alter database rename global_name to xx並不影響db_domain參數, 而建立db link時使用的是global_name而不是db_domain.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.