ORACLEµÄÈý¸öÅäÖÃÎļþ½éÉÜ
ÔÚoracle°²×°Ä¿Â¼$HOME/network/adminÏ£¬¾³£¿´µ½sqlnet.ora tnsnames.ora
listener.oraÕâÈý¸öÎļþ£¬³ýÁËtnsnames.ora£¬ÆäËûÁ½¸öÎļþÏêϸµÄÓÃ;ºÜ¶àÈ˶¼²»Ì«Á˽⡣
sqlnet.ora ÓÃÔÚoracle client¶Ë£¬ÓÃÓÚÅäÖÃÁ¬½Ó·þÎñ¶ËoracleµÄÏà¹Ø²ÎÊý.
tnsnames.ora ÓÃÔÚoracle
client¶Ë£¬Óû§ÅäÖÃÁ¬½ÓÊý¾Ý¿âµÄ±ðÃû²ÎÊý,¾ÍÏñϵͳÖеÄhostsÎļþÒ»Ñù¡£listener.ora ÓÃÔÚoracle
server¶Ë£¬ÅäÖÃoracle·þÎñ¶Ë³ÌÐòµÄ¼àÌý°ì·¨£¬±ÈÈçÏÞÖÆijЩipµÈ²ÎÊý¡£
ÔÚ°²×°Ä¿Â¼$HOME/network/admin/samplesÏ£¬»á¿´µ½ÈçÉÏÈý¸öÎļþµÄʾÀýÎļþ£¬ÀïÃæ»áÓÐÏà¹Ø²ÎÊýµÄ˵Ã÷ºÍÓ÷¨£¬Èç¹ûÓöµ½Ê²Ã´ÎÊ
Ì⣬´ó¼Ò¿ÉÒÔ¶ÔÕÕÕâЩʾÀýÎļþÖÐÏà¹Ø²ÎÊýµÄ˵Ã÷½øÐнâ¾ö¡£
Èç¹ûÁ¬½ÓÊý¾Ý¿â³öÁËʲôÎÊÌ⣬ÔÚ±£Ö¤ÍøÂç³öÕý³££¬Ã»ÓзÀ»ðǽ¸ÉÈŵÄÇé¿öÏ£¬²éÕÒÎÊÌâµÄ²½ÖèÊÇ:
1)ÔÚ¿Í»§¶Ë˳Ðò¼ì²ésqlnet.ora£¬tnsnames.oraÊÇÓÐÎÊÌâ¡£
2)ÔÚ·þÎñÆ÷¶Ë¼ì²élistener.oraÅäÖ㬲¢ÇÒ±£Ö¤¼àÌý³ÌÐòÆô¶¯£¬Êý¾Ý¿â·þÎñ¼ÓÔØ¡£
ÈÏʶsqlnet.ora
ÏÂÃæÖ»½²Êö¼¸¸ö³£ÓòÎÊýÅäÖã¬ÏêϸµÄ×ÊÁÏ£¬´ó¼Ò¿ÉÒԲ鿴ʾÀýsqlnet.oraµÃµ½¡£
sqlnet.ora¿ÉÒÔɾ³ý£¬ÕâÑùÔÚoracle¿Í»§¶ËÁ¬½ÓÊý¾Ý¿âµÄʱºò£¬Ä¬ÈϲÉÓÃtnsnames.oraÖеÄÅäÖá£
1).NAMES.DEFAULT_DOMAIN
ÓòÃûdomain¶¨Ò壬ÔÚÄãÓÃsqlplus·ÃÎÊÊý¾Ý¿âµÄʱºò,»áÔÚtns±ðÃûºóÃæ¼ÓÉÏ".domain"
ʾÀý:
sqlnet.oraÖÐ:
NAMES.DEFAULT_DOMAIN=com
tnsnames.oraÖеÄtns¶¨ÒåÈçÏÂ:
local_dev =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =
192.168.1.111)(PORT = 1521))
(CONNECT_DATA =
(SERVER =
DEDICATED)
(SERVICE_NAME = linuxdb)
)
)
ÔÚ¿Í»§¶ËÖ´ÐÐÃüÁî:sqlplus
[email=username/password@local_dev]username/password@local_dev[/email]µÄʱ
ºò£¬»á³öÏÖÈçÏ´íÎóÐÅÏ¢:
"ORA-12154: TNS: ÎÞ·¨´¦Àí·þÎñÃû"»òÕß"ORA-12154: TNS:could not resolve
service name"ÕâÑùµÄ´íÎóÐÅÏ¢¡£
ÒòΪsqlplus
[email=username/password@local_dev]username/password@local_dev[/email]µÄʱ
ºò£¬½«tns±ðÃû“local_dev”ת»»³ÉÁË“local_dev.com”£¬ËùÒÔlocal_dev.comÔÚtnsnames.oraÖÐÕÒ²»µ½£¬
¾Í±¨´íÁË¡£
ÐÞ¸Ätnsnames.oraÖеĶ¨ÒåÈç
Ïà¹ØÎĵµ£º
·ÖÒ³²éѯ¸ñʽ£º
SELECT * from
(
SELECT A.*, ROWNUM RN
from (SELECT * from TABLE_NAME) A
WHERE ROWNUM <= 40
)
WHERE RN >= 21
ÆäÖÐ×îÄÚ²ãµÄ²éѯSELECT * from TABLE_NAME±íʾ²»½øÐзҳµÄÔʼ²éѯÓï¾ä¡£ROWNUM <= 40ºÍRN >= 21¿ØÖÆ·ÖÒ³²éѯµÄÿҳµÄ·¶Î§¡£
ÉÏÃæ¸ø³öµÄÕâ¸ö·ÖÒ³²éѯÓï¾ä£¬ÔÚ´ó¶à ......
ÉÏһƪÎÄÕÂдÁËÒ»¸öoracleµÄÒ»¸öÐÐתÁеÄÀý×Ó£¬ÀïÃæÓõ½ÁËoracleÖÐÖØÒªµÄº¯Êý decode,ÕâƪÎÄÕ¾ÍÀ´¼òµ¥µÄѧϰÕâ¸öº¯Êý
DECODEº¯ÊýºÍÎÒÃÇÓïÑԽṹÖеÄÌõ¼þÓï¾ä£¨IF£©ÏàËÆ¡£Ëü½«ÊäÈëÊýÖµÓ뺯ÊýÖеIJÎÊýÁбíÏà±È½Ï£¬¸ù¾ÝÊäÈëÖµ·µ»ØÒ»¸ö¶ÔÓ¦Öµ¡£
DECODEº¯ÊýÏ൱ÓÚÒ»Ìõ¼þÓï¾ä(IF).Ëü½«ÊäÈëÊýÖµÓ뺯ÊýÖеIJÎÊýÁбíÏà±È½Ï£¬¸ù¾ÝÊ ......
create or replace type mytype IS TABLE OF varchar2(20);
declare type1 mytype :=mytype('1','2','3','4');
i number:=1;
var_str varchar(20):='liaomin';
begin
type1.EXTEND;
type1(type1.COUNT):=var_str;
loop
dbms_output.put_line(type1(i));
i:=i+1;
exit when i=type1.count+1; ......
create table a(
id number primary key,
name varchar2(20)
);
create table b(
id number,
name varchar2(20),
aid number references a(id)
);
insert into a values(1,'1');
insert into b values(1,'aaa',1);
Èç¹û create view vi_new as select * from a
ÔÚÊÓͼvi_new ÉÏ×öÈκΠdml²Ù×÷¶¼»áÐÞ¸Ä ¶ÔÓ¦µÄ ......
Oracle Ö÷ÒªÅäÖÃÎļþ½éÉÜ£¨×ªÌû£©
Oracle Ö÷ÒªÅäÖÃÎļþ½éÉÜ£º
profileÎļþ£¬oratab Îļþ£¬Êý¾Ý¿âʵÀý³õʼ»¯Îļþ initSID.ora£¬¼àÌýÅäÖÃÎļþ£¬ sqlnet.ora
Îļþ£¬tnsnames.ora Îļþ
1.2 Oracle Ö÷ÒªÅäÖÃÎļþ½éÉÜ
1.2.1 /etc/profile Îļþ
  ......