sql ²éѯÌõ¼þ×Ö¶ÎΪtext»òntext µÄ½â¾ö·½°¸
sql ²éѯÌõ¼þ×Ö¶ÎΪtext»òntextµÃ½â¾ö·½°¸ÒÔ¼°varchar(max)¡¢nvarchar(max)
1¡¢ÔÚMS SQL2005¼°ÒÔÉϵİ汾ÖУ¬¼ÓÈë´óÖµÊý¾ÝÀàÐÍ£¨varchar(max)¡¢nvarchar(max)¡¢varbinary(max) £©¡£´óÖµÊý¾ÝÀàÐÍ×î¶à¿ÉÒÔ´æ´¢2^30-1¸ö×Ö½ÚµÄÊý¾Ý¡£
Õ⼸¸öÊý¾ÝÀàÐÍÔÚÐÐΪÉϺͽÏСµÄÊý¾ÝÀàÐÍ varchar¡¢nvarchar ºÍ varbinary Ïàͬ¡£
΢ÈíµÄ˵·¨ÊÇÓÃÕâ¸öÊý¾ÝÀàÐÍÀ´´úÌæÖ®Ç°µÄtext¡¢ntext ºÍ image Êý¾ÝÀàÐÍ£¬ËüÃÇÖ®¼äµÄ¶ÔÓ¦¹ØÏµÎª£º
varchar(max)-------text;
nvarchar(max)-----ntext;
varbinary(max)----image.
ÓÐÁË´óÖµÊý¾ÝÀàÐÍÖ®ºó£¬ÔÚ¶Ô´óÖµÊý¾Ý²Ù×÷µÄʱºòÒª±ÈÒÔǰÁé»îµÄ¶àÁË¡£±ÈÈ磺֮ǰtextÊDz»ÄÜÓÑlike’µÄ£¬ÓÐÁËvarchar(max)Ö®ºó¾ÍûÓÐÕâЩÎÊÌâÁË£¬ÒòΪvarchar(max)ÔÚÐÐΪÉϺÍvarchar(n)ÉÏÏàͬ£¬ËùÒÔ£¬¿ÉÒÔÓÃÔÚvarcahrµÄ¶¼¿ÉÒÔÓÃÔÚvarchar(max)ÉÏ¡£
ËùÒÔÇëʹÓà varchar(max)¡¢nvarchar(max) ºÍ varbinary(max) Êý¾ÝÀàÐÍ£¬¶ø²»ÒªÊ¹Óà text¡¢ntext ºÍ image Êý¾ÝÀàÐÍ¡£
2¡¢Èç¹ûÐèÒª´¦ÀíÒѾ´æÔÚµÄtextÀàÐÍ µÄ²éѯ ÔòÐèÒª½øÐÐ×Ö¶Îת»»Ï where cast(text as varchar)
3¡¢ÊµÀýÈçÏ£¬ÆäÖÐi_itemΪntext
select * from IP_Investigate
where I_InvestigateID in (select IS_ID from IP_InvestigateStatus
where IS_Name like 'tomcat%') and cast(i_item as varchar)='1'
update IP_Investigate
set i_order=5
where I_InvestigateID in (select IS_ID from IP_InvestigateStatus
where IS_Name like 'tomcat%') and cast(i_item as varchar)='5'
Ïà¹ØÎĵµ£º
ALTER procedure [dbo].[sp_lock_check]
@spid1 int = NULL,
@spid2 int = NULL
as
set nocount on
if @spid1 is not NULL
begin
select ......
1¡¢ISNULL ( check_expression , replacement_value )
²ÎÊý
check_expression
½«±»¼ì²éÊÇ·ñΪ NULLµÄ±í´ïʽ¡£check_expression ¿ÉÒÔÊÇÈκÎÀàÐ͵ġ£
replacement_valueÔÚ check_expressionΪNULLʱ½«·µ»ØµÄ±í´ïʽ¡£replacement_value ±ØÐëÓë check_expresssion ¾ßÓÐÏàͬµÄÀàÐÍ¡£
·µ»ØÀàÐÍ
·µ»ØÓë check_expression Ï ......
1.³£Á¿
¶¨ÒåÓï·¨¸ñʽ£º
³£Á¿Ãû constant ÀàÐͱêʶ·û [not null]:=Öµ;
È磺PI constant number(9):=3.1415;
2.»ù±¾Êý¾ÝÀàÐͱäÁ¿
»ù±¾Êý¾ÝÀàÐÍ
number Êý×ÖÐÍ
int ÕûÊýÐÍ
pls_integer ÕûÊýÐÍ£¬²úÉúÒç³öʱ³öÏÖ´íÎó
binary_integer ÕûÊýÐÍ£¬±íʾ´ø·ûºÅµÄÕûÊý
char ¶¨³¤×Ö·ûÐÍ£¬×î´ó255¸ö×Ö·û
varchar2 ±ä³¤× ......
1.Ìõ¼þ¿ØÖÆ
1.1 if .. then .. end if
if Ìõ¼þ then
Óï¾ä¶Î£»
end if;
1.2 if .. then .. else .. end if
if Ìõ¼þ then
Óï¾ä¶Î£»
else
Óï¾ä¶Î£»
end if;
1.3 ifǶÌ×
2.Ñ»·¿ØÖÆ
2.1 loop .. exit .. end loop
loop
& ......
ÓαêÊÇ´ÓÊý¾Ý¿âÖÐÌáÈ¡³öÀ´µÄÊý¾Ý£¬ÒÔÁÙʱ±íµÄÐÎʽ´æ·ÅÔÚÄÚ´æÖУ¬ÔÚÓαêÖÐÓÐÒ»¸öÊý¾ÝÖ¸Õ룬ÔÚ³õʼ״̬ÏÂÖ¸ÏòÊ׼Ǽ£¬ ÀûÓÃfetchÓï¾äÒÆ¶¯¸ÃÖ¸Õ룬´Ó¶ø¶ÔÓαêÖеÄÊý¾Ý½øÐи÷ÖÖ²Ù×÷¡£
1.¶¨ÒåÓαê
cursor ÓαêÃû is selectÓï¾ä;
2.´ò¿ªÓαê
open ÓαêÃû;
3.ÌáÈ¡ÓαêÊý¾Ý
fetch ÓαêÃû into ±äÁ¿Ãû1, ±äÁ¿Ãû2, ....;
»ò
......