sql Áгö¿âÖÐËùÓÐ±í¼°×Ö¶ÎÏêϸÐÅÏ¢
--select name from sysobjects where type='U' order by name
SELECT
(case when a.colorder=1 then d.name else '' end) ±íÃû,
-- a.colorder ×Ö¶ÎÐòºÅ,
a.name ×Ö¶ÎÃû,
(case when COLUMNPROPERTY( a.id,a.name,'IsIdentity')=1 then '√'else '' end) ±êʶ,
(case when (SELECT count(*)
from sysobjects
WHERE (name in (SELECT name
from sysindexes
WHERE (id = a.id) AND (indid in (SELECT indid
from sysindexkeys
WHERE (id = a.id) AND (colid in (SELECT colid
from syscolumns
WHERE (id = a.id) AND (name = a.name)
)
)
)
)
)
) AND (xtype = 'PK')
) > 0 then '√' else '' end) Ö÷¼ü,
b.name ÀàÐÍ,
--a.length Õ¼ÓÃ×Ö½ÚÊý,
COLUMNPROPERTY(a.id,a.name,'PRECISION') as ³¤¶È,
--isnull(COLUMNPROPERTY(a.id,a.name,'Scale'),0) as СÊýλÊý,
(case when a.isnullable=1 then '√'else '' end) ÔÊÐí¿Õ,
isnull(e.text,'') ĬÈÏÖµ
--isnull(g.[value],'') AS ×Ö¶Î˵Ã÷
from syscolumns a
left join systypes b on a.xtype=b.xusertype
inner join sysobjects d on a.id=d.id and d.xtype='U' and d.name<>'dtproperties'
left join syscomments e on a.cdefault=e.id
--left join sysproperties g on a.id=g.id AND a.colid = g.sma
Ïà¹ØÎĵµ£º
1¡¢±à³ÌÓïÑÔÓëOracleÊý¾Ý¿â
1.1¡¢´æ´¢µÄÓëÄäÃûµÄPL/SQL³ÌÐò¿é
Óë´æ´¢µÄPL/SQL³ÌÐò¿éÏà±È£¬ÄäÃûµÄPL/SQL³ÌÐò¿éЧÂʽϵͣ¬´ËÍâÓÉÓÚ¿ÉÄÜÔÚ¶ą̀»úÆ÷Öй«²¼Ô´´úÂ룬»¹»áÒý·¢¹ÜÀíÎÊÌâ¡£
1.2¡¢PL/SQL¶ÔÏó
PL/SQL¶ÔÏó¾ßÓÐÏÂÁÐ5ÖÖÀàÐÍ£º
¹ý³Ì
º¯Êý
³ÌÐò°ü
³ÌÐò°üÖ÷Ìå
´¥·¢Æ÷
2¡¢¹ý³Ì¡¢º¯ÊýÒÔ¼°³ÌÐò°ü
2.1¡¢¹ý³ÌÓëº¯Ê ......
SQL Server 2005 ºÍ2008ÌṩÁ˺ܶàеĺÍÔöÇ¿µÄÉÌÎñÖÇÄܹ¦ÄÜ,°üÀ¨ÀûÓü¯³É·þÎñ(SSIS)ÕûºÏ¶àÖÖÊý¾ÝÔ´;ÀûÓ÷ÖÎö·þÎñ(SSAS)ʹÊý¾ÝÄÚÈݸü·á¸»²¢ÇÒ½¨Á¢¸´ÔÓµÄÉÌÒµ·ÖÎö; ÒÔ¼°ÀûÓñ¨±í·þÎñ(SSRS)±à¼,¹ÜÀí,ºÍÌá½»·á¸»µÄ±¨±í. Èç¹ûÄãÏÖÔÚ»¹²»Çå³þÕâЩ¹¦ÄÜ,ÄÇô½ÓÏÂÀ´Ò»ÏµÁеĽéÉÜ»áÈÃÄã¶ÔSQL ServerÏÖÔÚµÄÉÌÎñÖÇÄÜÖ§³Ö´ó³ÔÒ»¾ª.²»¹ý ......
1. ËÀËøÔÀí
¸ù¾Ý²Ù×÷ϵͳÖеĶ¨Ò壺ËÀËøÊÇÖ¸ÔÚÒ»×é½ø³ÌÖеĸ÷¸ö½ø³Ì¾ùÕ¼Óв»»áÊͷŵÄ×ÊÔ´£¬µ«Òò»¥ÏàÉêÇë±»ÆäËû½ø³ÌËùÕ¾Óò»»áÊͷŵÄ×ÊÔ´¶ø´¦ÓÚµÄÒ»ÖÖÓÀ¾ÃµÈ´ý״̬¡£
ËÀËøµÄËĸö±ØÒªÌõ¼þ£º
»¥³âÌõ¼þ(Mutual exclusion)£º×ÊÔ´²»Äܱ»¹²Ïí£¬Ö»ÄÜÓÉÒ»¸ö½ø³ÌʹÓá£
ÇëÇóÓë±£³ÖÌ ......
ÓÉÓÚÖÖÖÖÔÒò£¬ÎÒÃÇÈç¹ûµ±Ê±½ö½ö±¸·ÝÁËmdfµµ£¬ÄÇô»Ö¸´ÆðÀ´¾ÍÊÇÒ»¼þºÜÂé·³µÄÊÂÇéÁË¡£
Èç¹ûÄúµÄmdfµµÊǵ±Ç°×ÊÁÏ¿â²úÉúµÄ£¬ÄÇôºÜ½ÄÐÒ£¬Ò²ÐíÄãʹÓÃsp_attach_db»òÕßsp_attach_single_file_db¿ÉÒÔ»Ö¸´×ÊÁϿ⣬µ«ÊÇ»á³öÏÖÀàËÆÏÂÃæµÄÌáʾ×ÊѶ
É豸Æô¶¯´íÎó¡£ÎïÀíµµ°¸Ãû 'C:\Program Files\Microsoft SQL S ......
declare @i int
set @i=1
while @i<30
begin
insert into test (userid) values(@i)
set @i=@i+1
end
---------------
while Ìõ¼þ
begin
Ö´ÐвÙ×÷
set @i=@i+1
end
WHILE
ÉèÖÃÖظ´Ö´ÐÐ SQL Óï¾ä»òÓï¾ä¿éµÄÌõ¼þ¡£Ö»ÒªÖ¸¶¨µÄÌõ¼þΪÕ棬¾ÍÖظ´Ö´ÐÐÓï¾ä¡£¿ÉÒÔʹÓà BREAK ºÍ CONTINUE ¹Ø¼ü×ÖÔÚÑ»·ÄÚ²¿¿ØÖÆ W ......