SQLÊý¾ÝÀàÐÍ
Êý¾ÝÀàÐÍ:
Ò»¡¢ ÕûÊýÊý¾ÝÀàÐÍ
INT(INTEGER) 4
SMALLINT 2
TINYINT 1
BIGINT 8
¶þ¡¢ ¸¡µãÊý¾ÝÀàÐÍ
REAL ¾«È·µ½µÚ7 λСÊý 4
FLOAT ¾«È·µ½µÚ15 λСÊý 8
DECIMAL ¿ÉÒÔÌṩСÊýËùÐèÒªµÄʵ¼Ê´æ´¢¿Õ¼ä 2-17 decimal[p,[s]] decimal(6,2)
p ±íʾ¿É¹©´æ´¢µÄÖµµÄ×ÜλÊý£¨²»°üÀ¨Ð¡Êýµã£©£¬È±Ê¡ÖµÎª18£» s ±íʾСÊýµãºóµÄλÊý£¬È±Ê¡ÖµÎª0
NUMERIC ÓëDECIMALÊý¾ÝÀàÐÍÍêÈ«Ïàͬ
Èý¡¢¶þ½øÖÆÊý¾ÝÀàÐÍ
BINARY
VARBINARY BINARY(n) n ±íʾÊý¾ÝµÄ³¤¶È£¬È¡ÖµÎª1 µ½8000
ËÄ¡¢ Âß¼Êý¾ÝÀàÐÍ
BIT Õ¼ÓÃ1 ¸ö×ֽڵĴ洢¿Õ¼ä£¬ÆäֵΪ0 »ò1 ¡£Èç¹ûÊäÈë0 »ò1 ÒÔÍâµÄÖµ£¬½«±»ÊÓΪ1¡£ BIT ÀàÐͲ»Äܶ¨ÒåΪNULL Öµ£¨ËùνNULL ÖµÊÇÖ¸¿ÕÖµ»òÎÞÒâÒåµÄÖµ£©¡£
Îå¡¢×Ö·ûÊý¾ÝÀàÐÍ
CHAR CHAR ÀàÐÍ´æ´¢µÄÿ¸ö×Ö·ûºÍ·ûºÅÕ¼Ò»¸ö×ֽڵĴ洢¿Õ¼ä
NCHAR ²ÉÓÃUNICODE ±ê×¼×Ö·û¼¯,ËùÒÔËü±È·ÇUNICODE ±ê×¼µÄÊý¾ÝÀàÐͶàÕ¼ÓÃÒ»±¶µÄ´æ´¢¿Õ¼ä
VARCHAR
NVARCHAR
char=====>¹Ì¶¨³¤¶È char(10) Õ¼Ò»¸ö×Ö½Ú
varchar=====>¿É±ä³¤¶È varchar(10)
nchar====>unicode Õ¼Á½¸ö×Ö½Ú
Áù¡¢Îı¾ºÍͼÐÎÊý¾ÝÀàÐÍ
TEXT ÓÃÓÚ´æ´¢´óÁ¿Îı¾Êý¾Ý
NTEXT ²ÉÓÃUNICODE
IMAGE ´æ´¢Êý¾ÝµÄģʽÓëTEXT Êý¾ÝÀàÐÍÏàͬ ÓÃÓÚ´æ´¢´óÁ¿µÄ¶þ½øÖÆÊý¾Ý
address nvarchar(50)
introduct ntext
Æß ÈÕÆÚºÍʱ¼äÊý¾ÝÀàÐÍ
DATETIME
Ïà¹ØÎĵµ£º
´Ó²©¿ÍÔ°Öп´µ½Ò»ÆªÎÄÕ£¬½éÉÜ´óÈí¼þ¹«Ë¾ÃæÊÔʱ³£³£»á³öµÄÁ½µÀSQLÌ⣨¼û¸½Â¼£©¡£
ÎÒ¾õµÃÊÜÒæºÜ¶à£¬ÔÚ´Ë֮ǰ£¬ÎÒÒ»Ö±¾õµÃ£¬SQL2008ËƺõÌṩÁËÕâ·½ÃæµÄÖ§³Ö£¬µ«¸üµÍµÄ°æ±¾£¬°üÀ¨2005£¬·ÇÓαê×ö²»³öÀ´£¨Ë®Æ½¹»²Ë£©¡£×ܽáÐĵÃÈçÏ£º
1¡¢ Ç¿´óµÄgroup by
1 select stdname,
2 isnull( ......
¸ÅÊö
Microsoft SQL Server 2008 ÌṩÁËÓÐÖúÓÚÓÐЧ¹ÜÀí°²È«ÐÔ¹¦ÄÜÅäÖá¢Ç¿Éí·ÝÑéÖ¤ºÍ·ÃÎÊ¿ØÖƵݲȫÐÔÔöÇ¿¹¦ÄÜ¡¢¹¦ÄÜÇ¿´óµÄ¼ÓÃܺÍÃÜÔ¿¹ÜÀí¹¦ÄÜ£¬ÒÔ¼°ÔöÇ¿ÐÍÉóºË¹¦ÄÜ¡£
ÖØ´óµÄй¦ÄÜ
ʹÓûùÓÚ²ßÂԵĹÜÀí£¬Õë¶ÔÆóÒµÄÚµÄÊý¾ÝÀ´¹ÜÀí¼°¼ì²â²»·ûºÏ°²È«²ßÂÔµÄÇé¿ö
²»ÐèÐÞ¸ÄÓ¦ÓóÌÐò¼´¿ÉʹÓÃ͸Ã÷Êý¾Ý¼ÓÃÜÀ´¼ÓÃÜÊý¾Ý
ʹÓÿÉÀ© ......
insert into OPENROWSET('MICROSOFT.JET.OLEDB.4.0'
,'Excel 8.0;HDR=YES;DATABASE=c:\test.xls',sheet1$)
select * from ±íÃû
Èç¹ûÊÇÉú³Éexcel時ÓÃbcp
--µ¼³ö²éѯµÄÇé¿ö
EXEC master..xp_cmdshell 'bcp "SELECT au_fname, au_lname from pubs..authors ORDER BY au_lname" queryout "c:\test.xls" /c -/S"·þÎ ......
select * from ((select bill.id billId,bach.riskRate risk,bach.assureRate assure from AcptBillInfo bill,AcptBach bach where bill.acptBatchId=bach.id and bill.rgctId=? )abach left outer join AcptSignMoney sig on abach.billId = sig.billId) ......