你好,游客 登录 注册 搜索
背景:
阅读新闻

Oracle中的global_name和db domain

[日期:2012-08-04] 来源:Linux社区  作者:icybay [字体:大 中 小]

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.

linux
相关资讯       Oracle基础 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款