Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1418451
  • 博文数量: 239
  • 博客积分: 5909
  • 博客等级: 大校
  • 技术积分: 2715
  • 用 户 组: 普通用户
  • 注册时间: 2010-07-24 20:19
文章分类

全部博文(239)

文章存档

2014年(4)

2013年(22)

2012年(140)

2011年(14)

2010年(59)

我的朋友

分类: Oracle

2012-07-25 13:38:13


点击(此处)折叠或打开

  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.

阅读(1812) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~