oracle pl/sql ±à³Ì
µÚÒ»²¿·Ö »ù±¾¸ÅÄî
Ò»¡¢²éѯϵͳ±í
select * from user_tables ²éѯµ±Ç°Óû§ËùÓбí
select * from user_triggers ²éѯµ±Ç°Óû§ËùÓд¥·¢Æ÷
select * from user_procedures ²éѯµ±Ç°Óû§ËùÓд洢¹ý³Ì
¶þ¡¢·Ö×麯ÊýµÄÓ÷¨£º
max()
min()
avg()
sum()
count()
rollup()
×¢Ò⣺
1)·Ö×麯ÊýÖ»ÄܳöÏÖÔÚ group by ,having,order by ×Ó¾äÖУ¬²¢ÇÒorder by Ö»ÄÜ·ÅÔÚ×îºó
2)Èç¹ûÑ¡ÔñÁбíÖÐÓÐÁУ¬±í´ïʽºÍ·Ö×麯Êý£¬ÄÇôÁУ¬±í´ïʽ±ØÐëÒª³öÏÖÔÚgroup by º¯ÊýÖÐ
3)µ±ÏÞÖÆ·Ö×éÏÔʾ½á¹ûʱ£¬±ØÐë³öÏÖÔÚhaving×Ó¾äÖУ¬¶ø²»ÄÜÔÚwhere×Ó¾äÖÐ
rollup º¯Êý º¯ÊýÓÃÓÚÐγÉСºÏ¼Æ
Group by Ö»»áÉú³ÉÁÐÏàÓ¦Êý¾Ýͳ¼Æ
select deptno,job,avg(sal) from emp group by deptno,job;
rollup »áÔÚÔÀ´µÄͳ¼Æ»ù´¡ÉÏ£¬Éú³ÉСͳ¼Æ
select deptno,job,avg(sal) from emp group by rollup (deptno,job);
ÏÔʾÿ¸ö¸ÚλµÄƽ¾ù¹¤×Ê£¬Ã¿¸ö²¿ÃŵÄƽ¾ù¹¤×Ê£¬ºÍËùÓйÍÔ±µÄƽ¾ù¹¤×Ê
cube Ìṩ°´¶à¸ö×ֶλã×ܵŦÄÜ
ÏÔʾÿ¸ö²¿ÃÅÿ¸ö¸ÚλµÄƽ¾ù¹¤×Ê£¬Ã¿¸ö¸ÚλµÄƽ¾ù¹¤×Ê£¬Ã¿¸ö²¿ÃŵÄƽ¾ù¹¤×Ê£¬ºÍËùÓйÍÔ±µÄƽ¾ù¹¤×Ê
select deptno,job,avg(sal) from emp group by cube (deptno,job);
¶àÖÖ·Ö×éÊý¾Ý½á¹û grouping sets ²Ù×÷
ÏÔʾ²¿ÃÅƽ¾ù¹¤×Ê
select deptno,avg(sal) from emp group by emp.deptno,
ÏÔʾ¸Úλƽ¾ù¹¤×Ê
select job,avg(sal) from emp group by emp.job
ÏÔʾ²¿Ãź͸Úλƽ¾ù¹¤×Ê£¬ºÏ²¢ÉÏÃæÁ½¸ö½á¹û
select deptno,job,avg(sal) from emp group by grouping sets(emp.deptno,emp.job);
µÈ¼ÛÓë:
select deptno,null,avg(sal) from emp group by emp.deptno
union all
select null,job,avg(sal) from emp group by emp.job
Èý (+) Á¬½Ó
+ Ö»ÄÜÓÃÔÚwhere×Ó¾äÖУ¬¶øÇÒ·ÅÔÚÏÔʾ½ÏÉÙµÄÐÐÄÇÒ»±ß£¬²»ÄܺÍouter joinÓ﷨ͬʱʹÓÃ
+ Èç¹ûÔÚwhere ×Ó¾äÖÐÓжà¸öÌõ¼þ£¬Ã¿¸öÌõ¼þ¶¼±ØÐë¼ÓÉÏ+
+ ²»ÄÜÓÃÓÚ±í´ïʽ£¬Ö»ÄÜÓÃÓÚÁУ¬²»ÄܺÍin orÒ»ÆðʹÓá£
ËÄ ×Ö·ûº¯Êý
instr() substr() ltrim()
lower('SQL server') sql server&
Ïà¹ØÎĵµ£º
MSSQL:
declare @begin datetime
declare @End datetime
set @begin=getdate()
--Ö´ÐеÄÓï¾äдÔÚÕâÀï
set @End=getdate()
select datediff(millisecond,@begin,@End) as Ö´ÐеÄʱ¼ä
--millisecond±íʾºÁÃë Èç¹û¿´Ãë¿ÉÒÔʹÓÃss
C#:
ºÜ¶àʱº ......
¡¡¾ÍÈçͬÊý¾Ý¿âDBAÁ˽âµÄÒ»Ñù£¬ºÏÊʵÄË÷ÒýÄܹ»Ìá¸ß²éѯÐÔÄܺÍÓ¦ÓóÌÐò¿É²âÁ¿ÐÔ¡£µ«ÊÇÿ¸ö¸½¼ÓµÄË÷Òý£¬¶¼¸øϵͳÔö¼ÓÁ˶îÍ⿪Ïú£¬ÒòΪËæ×ÅÊý¾Ý´Ó±íºÍÊÓͼÖ⻶ÏÔö¼Ó¡¢Ð޸ĻòÇå³ý£¬SQL ServerÐèҪά»¤ÕâЩË÷Òý¡£
¡¡¡¡Ö®Ç°£¬ÎÒ½éÉÜÁËһ϶¯Ì¬¹ÜÀíÊÓͼ(DMV)¡£ËüÊÇÒ»ÖÖºÜÓÐÓõļà¿ØºÍ½â¾öSQL Server¹ÊÕϵŤ¾ß¡£±¾ÎÄÊÇËüµÄÐøƪ£¬ ......
×÷ΪһÃûÊý¾Ý¿âDBA£¬¿Ï¶¨»áÌý˵¹ý“tempdbÊý¾Ý¿âÂúÁË”¡£Í¨³£ÎÒÃǺÜÈÝÒ×È·¶¨Ôì³ÉÕâÒ»ÎÊÌâµÄÔÒò¡£µ«ÊǸü¶àµÄʱºòÕâÒ»ÎÊÌâÖ÷ÒªÔ´ÓÚÒ»×éÇëÇó£¬Éæ¼°µ½Ð´úÂ벿Êð»òÖð½¥Ôö¼ÓµÄÊý¾Ý¡£
¡¡¡¡“TempdbÂúÁË”Òâζ×Åʲô?
¡¡¡¡µ±SQL Server tempdbÂúÁËʱ£¬Éϲã¹ÜÀí³£³£ÐèÒª¾ö²ß¡¢Ò»Ð©¿ª·¢ÈËÔ±¿ÉÄÜ»áÍÆжÔðÈΣ¬¾ ......
SQL Server 2008ÖÐ×îеÄÎļþÁ÷¹¦ÄÜʹµÃÄã¿ÉÒÔÅäÖÆÒ»¸öÊý¾ÝÀàÐÍΪvarbinary(max)µÄÁУ¬ÒԱ㽫ʵ¼ÊÊý¾Ý´æ´¢ÔÚÎļþϵͳÖУ¬¶ø·ÇÔÚÊý¾Ý¿âÖС£Ö»ÒªÔ¸Ò⣬ÄãÈÔ¿ÉÒÔ×÷Ϊһ¸ö³£¹æµÄ¶þ½øÖÆÁÐÀ´²éѯ´ËÁУ¬¼´Ê¹Êý¾Ý×ÔÉí´æ´¢ÔÚÍⲿ¡£
¡¡¡¡ÎļþÁ÷ÌØÐÔͨ¹ý½«¶þ½øÖÆ´ó×Ö¶ÎÊý¾Ý´æ´¢ÔÚ±¾µØÎļþϵͳÖÐ,´Ó¶ø½«Windowsм¼ÊõÎļþϵͳ(NTFS)ºÍS ......