SQL³£ÓÃÈÕÆÚʱ¼ä´¦Àíº¯Êý
×î½üÔÚÔÚÒ»µçÁ¦ÏµÍ³£¬ÀïÃæÓõ½±¨±í£¬¾³£ÐèÒª¶ÔSQLÈÕÆÚ½øÐвÙ×÷¡£ÏÖÔÚ½«Ò»Ð©³£ÓõÄSQLÈÕÆÚ²Ù×÷º¯Êý¼ÇÏÂ
/**//**//**//* datepart()º¯ÊýµÄʹÓà ¡¡¡¡
* datepart()º¯Êý¿ÉÒÔ·½±ãµÄÈ¡µ½Ê±ÆÚÖеĸ÷¸ö²¿·Ö
*ÈçÈÕÆÚ£º2006-07--02 18£º15£º36.513
* yy:È¡Äê ¡¡¡¡2006
* mm:È¡ÔÂ ¡¡¡¡7
* dd:È¡ÔÂÖеÄÌì ¡¡¡¡2
* dy:È¡ÄêÖеÄÌì ¡¡¡¡183
* wk:È¡ÄêÖеÄÖÜ ¡¡¡¡27
* dw:È¡ÖÜÖеÄÌì ¡¡¡¡1
* qq:È¡ÄêÖеļ¾¶È 3
* hh:ȡСʱ ¡¡¡¡18
* mi:È¡·ÖÖÓ ¡¡¡¡15
* ss:È¡Ãë ¡¡¡¡36
* ÒÔϼòµ¥µÄÓï¾ä¿ÉÒÔÑÝʾËùÈ¡µ½µÄ½á¹û
*/
select getdate()
select datepart(mm,getdate())
select datepart(yy,getDate())
select datepart(dd,getdate())
select datepart(dy,getdate())
select datepart(wk,getdate())
select datepart(dw,getdate())
select datepart(qq,getdate())
select datepart(hh,getdate())
select datepart(mi,getdate())
select datepart(ss,getdate())
select datediff(dd,getdate(),'12/25/2006')--¼ÆËã´Ó½ñÌìµ½12/25/2006»¹ÓжàÉÙÌì
select datediff(mm,getdate(),'12/25/2006')--¼ÆËã´Ó½ñÌìµ½12/25/2006»¹ÓжàÉÙ¸öÔÂ
select datename(mm,getdate()) ¡¡¡¡--ÒÔ×Ö·û´®¶ø²»ÊÇÊý×ÖµÄÐÎʽµÃµ½½ñÌìµÄÔ·ݣ¨07£©
select dateadd(dd,30,getdate()) ¡¡¡¡--ÔÚÄ¿Ç°µÄÈÕÆÚÈÕÆÚÉϼÓ30Ìì
select dateadd(mm,3,getdate()) ¡¡¡¡--ÔÚÄ¿Ç°µÄÈÕÆÚÈÕÆÚÉϼÓ3¸öÔÂ
select dateadd(yy,1,getdate()) ¡¡¡¡--ÔÚÄ¿Ç°µÄÈÕÆÚÈÕÆÚÉϼÓ1Äê
select DATEADD(qq,DATEDIFF(qq,0,getdate()), 0)--µÃµ½±¾¼¾¶ÈµÚÒ»Ìì
select dateadd(mm,-3,DATEADD(qq, DATEDIFF(qq,0,getdate()), 0)) --µÃµ½ÉÏÖ÷¡¢¼¾¶ÈµÚÒ»Ìì--ÁíÍâʹÓÃgetdate()
º¯Êý·µ»ØµÄÈÕÆÚ°üÀ¨µ½ºÁÃ뼶£¬ÓÐʱÎÒÃÇÖ»ÐèҪȡ³öÒ»²¿·ÖÈç 200
Ïà¹ØÎĵµ£º
ϵͳ»·¾³£ºWindows 7
Èí¼þ»·¾³£ºVisual C++ 2008 SP1 +SQL Server 2005
±¾´ÎÄ¿µÄ£º±àдһ¸öº½¿Õ¹ÜÀíϵͳ
ÕâÊÇÊý¾Ý¿â¿Î³ÌÉè¼ÆµÄ³É¹û£¬ËäÈ»³É¼¨²»¼Ñ£¬µ«ÊÇ×÷ΪÎÒÓÃVC++ ÒÔÀ´±àдµÄ×î´ó³ÌÐò»¹ÊÇ´«µ½ÍøÉÏ£¬ÒÔ¹©²Î¿¼¡£ÓÃVC++ ×öÊý¾Ý¿âÉè¼Æ²¢²»ÈÝÒ×£¬µ«Ò²²»ÊDz»¿ÉÄÜ¡£ÒÔÏÂÊÇÎҵijÌÐò½çÃ棬ºóÃæ ......
CREATE PROCEDURE dbo.OutputData
@tablename varchar(200)
AS
declare @column varchar(1000)
declare @ ......
´´½¨×éºÏ²éѯ
¿ÉÓÃUNION²Ù×÷·ûÀ´×éºÏÊýÌõSQL²éѯ¡£ÀûÓÃUNION£¬¿É¸ø³ö¶àÌõSELECTÓï¾ä£¬½«ËüÃǵĽá¹û×éºÏ³Éµ¥¸ö½á¹û¼¯¡£
16.2.1 ʹÓÃUNION
UNIONµÄʹÓúܼòµ¥¡£ËùÐè×öµÄÖ»ÊǸø³öÿÌõSELECTÓï¾ä£¬ÔÚ¸÷ÌõÓï¾äÖ®¼ä·ÅÉϹؼü×ÖUNION¡£
¾ÙÒ»¸öÀý×Ó£¬¼ÙÈçÐèÒª¼Û¸ñСÓÚµÈÓÚ5µÄËùÓÐÎïÆ·µÄÒ»¸öÁÐ±í£¬¶øÇÒ»¹Ïë°üÀ¨¹©Ó¦ÉÌ1001ºÍ1002É ......
oracle³£ÓþµäSQL²éѯ
³£ÓÃSQL²éѯ£º
1¡¢²é¿´±í¿Õ¼äµÄÃû³Æ¼°´óС
select t.tablespace_name, round(sum(bytes/(1024*1024)),0) ts_size
from dba_tablespaces t, dba_data_files d
where t.tablespace_name = d.tablespace_name
group by t.tablespace_name;
2¡¢²é¿´±í¿Õ¼äÎïÀíÎļþµÄÃû³Æ ......
SQL²Ù×÷È«¼¯
ÏÂÁÐÓï¾ä²¿·ÖÊÇMssqlÓï¾ä£¬²»¿ÉÒÔÔÚaccessÖÐʹÓá£
SQL·ÖÀࣺ
DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
DML—Êý¾Ý²Ù×ÝÓïÑÔ(SELECT£¬DELETE£¬UPDATE£¬INSERT)
DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
CREATE ......