SQL SERVERÖÐTimeStampʹÓÃ
SQL ServerÖÐÁª»ú´ÔÊé
SQL Server timestamp Êý¾ÝÀàÐÍÓëʱ¼äºÍÈÕÆÚÎ޹ء£SQL Server timestamp ÊǶþ½øÖÆÊý×Ö£¬Ëü±íÃ÷Êý¾Ý¿âÖÐÊý¾ÝÐ޸ķ¢ÉúµÄÏà¶Ô˳Ðò¡£ÊµÏÖ timestamp Êý¾ÝÀàÐÍ×î³õÊÇΪÁËÖ§³Ö SQL Server »Ö¸´Ëã·¨¡£Ã¿´ÎÐÞ¸Äҳʱ£¬¶¼»áʹÓõ±Ç°µÄ @@DBTS Öµ¶ÔÆä×öÒ»´Î±ê¼Ç£¬È»ºó @@DBTS ¼Ó1¡£ÕâÑù×ö×ãÒÔ°ïÖú»Ö¸´¹ý³ÌÈ·¶¨Ò³Ð޸ĵÄÏà¶Ô´ÎÐò£¬µ«ÊÇ timestamp ÖµÓëʱ¼äûÓÐÈκιØϵ¡£
timestamp ÕâÖÖÊý¾ÝÀàÐͱíÏÖ×Ô¶¯Éú³ÉµÄ¶þ½øÖÆÊý£¬È·±£ÕâЩÊýÔÚÊý¾Ý¿âÖÐÊÇΨһµÄ¡£timestamp Ò»°ãÓÃ×÷¸ø±íÐмӰ汾´ÁµÄ»úÖÆ¡£´æ´¢´óСΪ 8 ×Ö½Ú¡£
Transact-SQL timestamp Êý¾ÝÀàÐÍÓëÔÚ SQL-92 ±ê×¼Öж¨ÒåµÄ timestamp Êý¾ÝÀàÐͲ»Í¬¡£SQL-92 timestamp Êý¾ÝÀàÐ͵ȼÛÓÚ Transact-SQL datetime Êý¾ÝÀàÐÍ¡£
Microsoft® SQL Server™ ½«À´µÄ°æ±¾¿ÉÄÜ»áÐÞ¸Ä Transact-SQL timestamp Êý¾ÝÀàÐ͵ÄÐÐΪ£¬Ê¹ËüÓëÔÚ±ê×¼Öж¨ÒåµÄÐÐΪһÖ¡£µ½ÄÇʱ£¬µ±Ç°µÄ timestamp Êý¾ÝÀàÐͽ«Óà rowversion Êý¾ÝÀàÐÍÌæ»»¡£
Microsoft® SQL Server™ 2000 ÒýÈëÁË timestamp Êý¾ÝÀàÐ굀 rowversion ͬÒå´Ê¡£ÔÚ DDL Óï¾äÖо¡¿ÉÄÜʹÓà rowversion ¶ø²»Ê¹Óà timestamp¡£rowversion ÊÜÊý¾ÝÀàÐÍͬÒå´ÊÐÐΪµÄÖÆÔ¼¡£Óйظü¶àÐÅÏ¢£¬Çë²Î¼ûÊý¾ÝÀàÐÍͬÒå´Ê¡£
ÔÚ CREATE TABLE »ò ALTER TABLE Óï¾äÖУ¬²»±ØΪ timestamp Êý¾ÝÀàÐÍÌṩÁÐÃû£º
CREATE TABLE ExampleTable (PriKey int PRIMARY KEY, timestamp)
Èç¹ûûÓÐÌṩÁÐÃû£¬SQL Server ½«Éú³É timestamp µÄÁÐÃû¡£rowversion Êý¾ÝÀàÐÍͬÒå´Ê²»¾ßÓÐÕâÑùµÄÐÐΪ¡£Ö¸¶¨ rowversion ʱ±ØÐëÌṩÁÐÃû¡£
Ò»¸ö±íÖ»ÄÜÓÐÒ»¸ö timestamp ÁС£Ã¿´Î²åÈë»ò¸üаüº¬ timestamp ÁеÄÐÐʱ£¬timestamp ÁÐÖеÄÖµ¾ù»á¸üС£ÕâÒ»ÊôÐÔʹ timestamp Áв»ÊʺÏ×÷Ϊ¼üʹÓã¬ÓÈÆäÊDz»ÄÜ×÷ΪÖ÷¼üʹÓ᣶ÔÐеÄÈκθüж¼»á¸ü¸Ä timestamp Öµ£¬´Ó¶ø¸ü¸Ä¼üÖµ¡£Èç¹û¸ÃÁÐÊôÓÚÖ÷¼ü£¬ÄÇô¾ÉµÄ¼üÖµ½«ÎÞЧ£¬½ø¶øÒýÓøþÉÖµµÄÍâ¼üÒ²½«²»ÔÙÓÐЧ¡£Èç¹û¸Ã±íÔÚ¶¯Ì¬ÓαêÖÐÒýÓã¬ÔòËùÓиüоù»á¸ü¸ÄÓαêÖÐÐеÄλÖá£Èç¹û¸ÃÁÐÊôÓÚË÷Òý¼ü£¬Ôò¶ÔÊý¾ÝÐеÄËùÓиüл¹½«µ¼ÖÂË÷Òý¸üС£
²»¿ÉΪ¿ÕµÄ timestamp ÁÐÔÚÓïÒåÉϵȼÛÓÚ binary(8) ÁС£
Ïà¹ØÎĵµ£º
¸ø´ó¼Ò¸öѧϰÊý¾Ý¿âµÄÈí¼þ°É£¬sql server 2008£¬Õâ¸öÊÇ΢Èí¹«Ë¾µÄ×÷Æ·£¬²»´í£¬Ó¦¸ÃÊǷdz£²»´í£¬ÔÚµçÄÔÉÏ°²×°OracleÊý¾Ý¿âµÄ»°£¬ÄǸö±È½Ï´ó£¬¶øÇÒÔÚÍøÉÏÒ²²»ºÃÏÂÔØ£¬ÒªÊÇÁ¬½Óµ½Ñ§Ð£·þÎñÆ÷µÄ»°£¬Ò²ÊDz»¿ÉÄܵģ¬³ý·Ç´ó¼Ò¾³£È¥»ú·¿ÉÏ»ú£¬µ«ÊÇÄǸöÒ²²»¿ª£¬·Ï»°²»¶à˵ÁË£¬´ó¼Òȥ΢Èí¹ÙÍøÏÂÔØÒ»¸ösql server 2008µÄÊÔÓðæµÄ°²×°ÎÄ ......
ÏÂÁÐÓï¾ä²¿·ÖÊÇMssqlÓï¾ä£¬²»¿ÉÒÔÔÚaccessÖÐʹÓá£
SQL·ÖÀࣺ
DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
DML—Êý¾Ý²Ù×ÝÓïÑÔ(SELECT£¬DELETE£¬UPDATE£¬INSERT)
DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£ ......
·ÖÀàͳ¼Æ×ÜÊý²¢ÅÅÐò¶à±íÁªºÏ²éѯµÄÁ½ÖÖ·½·¨
Àý:
²éѯµØÇø±íÖи÷Ê¡ÏÂÃæ³ÇÊÐ×ÜÊý,²¢¶Ô²éѯ½á¹ûÈ¡Ç°Ê®Ãû
·¨Ò»:
select b.id,a.[name],b.counts from n_area a,(select top 10 parent_id as id,sum(parent_id) as counts from n_area where parent_id<>0 group by parent_id order by sum(parent_id) desc
) b where ......
DECLARE @T varchar(255),
@C varchar(255)
DECLARE Table_Cursor CURSOR FOR
Select
a.name,b.name
from sysobjects a,
syscolumns b
where a.id=b.id and
a.xtype='u' and
(b.xtype=99 or b.xtype=35 or b.xtype=231 or b.xtype=167)
OPEN Table_Cursor
FETCH NEXT from Table_Cursor INTO @T,@C
WHILE(@@FET ......
ÈçºÎÓÅ»¯SQL Server
1¡¢ ÓóÌÐòÖУ¬±£Ö¤ÔÚʵÏÖ¹¦ÄܵĻù´¡ÉÏ£¬¾¡Á¿¼õÉÙ¶ÔÊý¾Ý¿âµÄ·ÃÎÊ´ÎÊý£»Í¨¹ýËÑË÷²ÎÊý£¬¾¡Á¿¼õÉÙ¶Ô±íµÄ·ÃÎÊÐÐÊý,×îС»¯½á¹û¼¯£¬´Ó¶ø¼õÇáÍøÂ縺µ££»Äܹ»·Ö¿ªµÄ ²Ù×÷¾¡Á¿·Ö¿ª´¦Àí£¬Ìá¸ßÿ´ÎµÄÏìÓ¦Ëٶȣ»ÔÚÊý¾Ý´°¿ÚʹÓÃSQLʱ£¬¾¡Á¿°ÑʹÓõÄË÷Òý·ÅÔÚÑ¡ÔñµÄÊ×ÁУ»Ëã·¨µÄ½á¹¹¾¡Á¿¼òµ¥£»ÔÚ²éѯʱ£¬²»Òª¹ý¶ ......