Oracle תÒå×Ö·û
Ò»¡¢×¼±¸ÌØÊâÊý¾Ý
create table t_escape(s varchar2(50));
--show define -- define "&" (hex 26)
--show escape -- escape off
set define off
set escape on
insert into t_escape values('string&text');
insert into t_escape values('string\&text');
insert into t_escape values('string\%text');
insert into t_escape values('string\_text');
insert into t_escape values('string''text');
set escape off
set define on
insert into t_escape values('Top_Gun');
insert into t_escape values('Tom''s eye');
insert into t_escape values('normal');
insert into t_escape values('100%ps');
insert into t_escape values('12345');
insert into t_escape values('15%30');
insert into t_escape values('%40');
insert into t_escape values('25%XT');
insert into t_escape values('%%A3E5');
set define off
--Ö±½Ó²åÈëÈçÏÂÊý¾Ýʱ£¬²åÈë½á¹û²»ÕýÈ·¡£
insert into t_escape values('T&T Company');
set define on
commit;
/
¶þ¡¢Ê¹ÓÃתÒå²éѯ
[½ç¶¨·û][תÒå·û]%'escape'[½ç¶¨·û] ΪתÒ嶨Ò壬Èç
תÒå_£¬Ê¹ÓÃ$_%'escape'$£¬ÕâÀï½ç¶¨·ûÊÇ$¡£
select * from t_escape where s like 'Top$_%'escape'$';
½ç¶¨·û¿ÉÒÔÊÇ¿Õ¸ñ,\,=,/,|£¬²»ÄÜÊÇ×Öĸ¡£
Àý£¬²éÕÒº¬ÓÐ'%'µÄËùÓÐ×ֶΣº
select * from t_escape where s like '%\%%' escape '\';
'&'²»ÄÜͨ¹ýתÒå×Ö·û²éÕÒ£º
select * from t_escape where s like '%\&%' escape'\';
¿ÉÒÔͨ¹ýÁíÍâµÄ·½Ê½½øÐÐתÒ壺
select ascii('&') from dual; -- ASCII = 38
select * from t_escape where s like '%'||chr(38)||'%';
²éÕÒµ¥ÒýºÅ£º
select * from t_escape where s like '%''%';
Ïà¹ØÎĵµ£º
°²×°Oracle Database(10.0.2)ºó£¬Èç¹ûÐ޸ĻúÆ÷Ãûºó£¬
»áµ¼Ö¿ØÖÆÃæ°åµÄ·þÎñÖÐÆô¶¯OracleTNSLisener·þÎñÁ¢¿Ì¾ÍÍ£Ö¹¡£
ʹÓÃÃüÁîÐй¤¾ß£¬ÌáʾÈçÏ£º
(»úÆ÷ÃûÔÀ´Îª£ºANSWER-1738E000£¬¸ÄΪ£ºANSWER)
½â¾ö·½·¨£º
1>¹Øµô¿ØÖÆÃæ°åÖÐÓйØÓÚ Oracle Database µÄ·þÎñ¡£
2>ÐÞ¸Ä C:\oracle\product\10.2.0\db_1\NE ......
Ubuntu9.04ÏÂOracleÊÖ¶¯Æô¶¯Óë×ÔÆô¶¯½Å±¾
Ò»¡¢Æô¶¯Êý¾Ý¿âʵÀý
Java´úÂë
gengzhi
@gengzhi
-desktop:~$ su oracle
oracle@gengzhi
-desktop:~$ sqlplus
" scott/tiger as sysdba"
gengzhi@gengzhi-desktop:~$ s ......
1.¶à°æ±¾£º¶ÁÒ»Ö²éѯ ·Ç×èÈû²éѯ
Oracle ²ÉÓÃÁËÒ»ÖÖ
¶à°æ±¾¡¢¶ÁÒ»Ö£¨read-consistent£©µÄ²¢·¢Ä£ÐÍ¡£ÔÙ´Î˵Ã÷£¬ÎÒÃǽ«ÔÚµÚ7 Õ¸üÏêϸµØ½éÉÜÓйصļ¼Êõ¡£
²»¹ý£¬ÊµÖÊÉϽ²£¬Oracle ÀûÓÃÕâÖÖ»úÖÆÌṩÁËÒÔÏÂÌØÐÔ£º
¶ÁÒ»Ö²éѯ£º¶ÔÓÚÒ»¸öʱ¼äµã£¨point in time£©£¬²éѯ»á²úÉúÒ»ÖµĽá¹û¡£
·Ç×èÈû²éѯ£º²éѯ²»» ......
1.¾¡¿ÉÄܵØʹÓð󶨱äÁ¿ ²»Óÿª¹ØCURSOR_SHARING=FORCE
Èç¹ûÄãÔ¸Ò⣬Õâ¸öÌØÐÔ»áʵÏÖÒ»¸ö×Ô¶¯°ó¶¨Æ÷£¨auto-binder£©¡£
Èç¹ûÓÐÒ»¸ö²éѯ±àдΪSELECT * from EMP WHERE EMPNO = 1234£¬×Ô¶¯°ó¶¨Æ÷»áÇÄÎÞÉùÏ¢µØ°ÑËü¸Äд³É
SELECT * from EMP WHERE EMPNO = :x¡£ÕâȷʵÄܶ¯Ì¬µØ´ó´ó¼õÉÙÓ²½âÎöÊý£¬²¢¼õÉÙÇ°ÃæÌÖÂÛµ ......
°Ñ×Ô¼ºËѼ¯µÄ×ÊÁÏÌù³öÀ´£¬Ñ§Ï°¹¤×÷·½±ãÕ¼¡£
SQLÖеĵ¥¼Ç¼º¯Êý
1.ASCII
·µ»ØÓëÖ¸¶¨µÄ×Ö·û¶ÔÓ¦µÄÊ®½øÖÆÊý;
SQL> select ascii('A') A,ascii('a') a,ascii('0') zero,ascii(' ') space from dual;
A A ZERO SPACE
--------- --------- --------- ---------
65 97 48 32
2.CHR
¸ø³öÕûÊý,·µ»Ø¶ÔÓ¦µÄ×Ö·û;
SQ ......