SQL ServerÊý¾ÝÀàÐͽéÉÜ
ÔÚ¼ÆËã»úÖÐÊý¾ÝÓÐÁ½ÖÖÌØÕ÷£ºÀàÐͺͳ¤¶È¡£ËùνÊý¾ÝÀàÐ;ÍÊÇÒÔÊý¾ÝµÄ±íÏÖ·½Ê½ºÍ´æ´¢·½Ê½À´»®·ÖµÄÊý¾ÝµÄÖÖÀà¡£
ÔÚSQL Server ÖÐÿ¸ö±äÁ¿¡¢²ÎÊý¡¢±í´ïʽµÈ¶¼ÓÐÊý¾ÝÀàÐÍ¡£ÏµÍ³ÌṩµÄÊý¾ÝÀàÐÍ·ÖΪ¼¸´óÀ࣬Èç±í4-2 Ëùʾ¡£
ÆäÖУ¬BIGINT¡¢ SQL_VARIANT ºÍTABLE ÊÇSQL Server 2000 ÖÐÐÂÔö¼ÓµÄ3 ÖÖÊý¾ÝÀàÐÍ¡£ÏÂÃæ·ÖÀིÊö¸÷ÖÖÊý¾ÝÀàÐÍ¡£
Ò»¡¢ ÕûÊýÊý¾ÝÀàÐÍ
ÕûÊýÊý¾ÝÀàÐÍÊÇ×î³£ÓõÄÊý¾ÝÀàÐÍÖ®Ò»¡£
1¡¢INT £¨INTEGER£©
INT £¨»òINTEGER£©Êý¾ÝÀàÐÍ´æ´¢´Ó-2µÄ31´Î·½ £¨-2 £¬147 £¬483 £¬648£© µ½2µÄ31´Î·½-1 £¨2 £¬147 £¬483£¬647£© Ö®¼äµÄËùÓÐÕý¸ºÕûÊý¡£Ã¿¸öINT ÀàÐ͵ÄÊý¾Ý°´4 ¸ö×Ö½Ú´æ´¢£¬ÆäÖÐ1 λ±íʾÕûÊýÖµµÄÕý¸ººÅ£¬ÆäËü31 λ±íʾÕûÊýÖµµÄ³¤¶ÈºÍ´óС¡£
2¡¢SMALLINT
SMALLINT Êý¾ÝÀàÐÍ´æ´¢´Ó-2µÄ15´Î·½£¨ -32£¬ 768£© µ½2µÄ15´Î·½-1£¨ 32 £¬767 £©Ö®¼äµÄËùÓÐÕý¸ºÕûÊý¡£Ã¿¸öSMALLINT ÀàÐ͵ÄÊý¾ÝÕ¼ÓÃ2 ¸ö×ֽڵĴ洢¿Õ¼ä£¬ÆäÖÐ1 λ±íʾÕûÊýÖµµÄÕý¸ººÅ£¬ÆäËü15 λ±íʾÕûÊýÖµµÄ³¤¶ÈºÍ´óС¡£
3¡¢TINYINT
TINYINTÊý¾ÝÀàÐÍ´æ´¢´Ó0 µ½255 Ö®¼äµÄËùÓÐÕýÕûÊý¡£Ã¿¸öTINYINTÀàÐ͵ÄÊý¾ÝÕ¼ÓÃ1 ¸ö×ֽڵĴ洢¿Õ¼ä¡£
4¡¢BIGINT
BIGINT Êý¾ÝÀàÐÍ´æ´¢´Ó-2^63 £¨-9 £¬223£¬ 372£¬ 036£¬ 854£¬ 775£¬ 807£© µ½2^63-1£¨ 9£¬ 223£¬ 372£¬ 036 £¬854 £¬775£¬ 807£© Ö®¼äµÄËùÓÐÕý¸ºÕûÊý¡£Ã¿¸öBIGINT ÀàÐ͵ÄÊý¾ÝÕ¼ÓÃ8¸ö×ֽڵĴ洢¿Õ¼ä¡£
¶þ¡¢ ¸¡µãÊý¾ÝÀàÐÍ
¸¡µãÊý¾ÝÀàÐÍÓÃÓڴ洢ʮ½øÖÆСÊý¡£¸¡µãÊýÖµµÄÊý¾ÝÔÚSQL Server ÖвÉÓÃÉÏÉáÈ루Round up »ò³ÆΪֻÈë²»Éᣩ·½Ê½½øÐд洢¡£ËùνÉÏÉáÈëÊÇÖ¸£¬µ±£¨ÇÒ½öµ±£©ÒªÉáÈëµÄÊýÊÇÒ»¸ö·ÇÁãÊýʱ£¬¶ÔÆä±£ÁôÊý×Ö²¿·ÖµÄ×îµÍÓÐЧλÉϵÄÊýÖµ¼Ó1 £¬²¢½øÐбØÒªµÄ½øλ¡£ÈôÒ»¸öÊýÊÇÉÏÉáÈëÊý£¬Æä¾ø¶ÔÖµ²»»á¼õÉÙ¡£È磺¶Ô3.14159265358979 ·Ö±ð½øÐÐ2 λºÍ12λÉáÈ룬½á¹ûΪ3.15 ºÍ3.141592653590¡£
1¡¢REAL Êý¾ÝÀàÐÍ
REALÊý¾ÝÀàÐͿɾ«È·µ½µÚ7 λСÊý£¬Æ䷶ΧΪ´Ó-3.40E -38 µ½3.40E +38¡£ ÿ¸öREALÀàÐ͵ÄÊý¾ÝÕ¼ÓÃ4 ¸ö×ֽڵĴ洢¿Õ¼ä¡£
2¡¢FLOAT
FLOAT Êý¾ÝÀàÐͿɾ«È·µ½µÚ15 λСÊý£¬Æ䷶ΧΪ´Ó-1.79E -308 µ½1.79E +308¡£ ÿ¸öFLOA
Ïà¹ØÎĵµ£º
´´½¨×éºÏ²éѯ
¿ÉÓÃUNION²Ù×÷·ûÀ´×éºÏÊýÌõSQL²éѯ¡£ÀûÓÃUNION£¬¿É¸ø³ö¶àÌõSELECTÓï¾ä£¬½«ËüÃǵĽá¹û×éºÏ³Éµ¥¸ö½á¹û¼¯¡£
16.2.1 ʹÓÃUNION
UNIONµÄʹÓúܼòµ¥¡£ËùÐè×öµÄÖ»ÊǸø³öÿÌõSELECTÓï¾ä£¬ÔÚ¸÷ÌõÓï¾äÖ®¼ä·ÅÉϹؼü×ÖUNION¡£
¾ÙÒ»¸öÀý×Ó£¬¼ÙÈçÐèÒª¼Û¸ñСÓÚµÈÓÚ5µÄËùÓÐÎïÆ·µÄÒ»¸öÁÐ±í£¬¶øÇÒ»¹Ïë°üÀ¨¹©Ó¦ÉÌ1001ºÍ1002É ......
Ò»¡¢»ù´¡
1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
CREATE DATABASE database-name
2¡¢ËµÃ÷£ºÉ¾³ýÊý¾Ý¿â
drop database dbname
3¡¢ËµÃ÷£º±¸·Ýsql server
--- ´´½¨±¸·ÝÊý¾ÝµÄ device
USE master
EXEC sp_addumpdevice 'disk', 'testBack', 'c:mssql7backupMyNwind_1.dat'
--- ¿ªÊ¼±¸·Ý
BACKUP DATABASE pubs TO testBack
......
SQLÀïµÄEXISTSÓëin¡¢not existsÓënot in
ϵͳҪÇó½øÐÐSQLÓÅ»¯£¬¶ÔЧÂʱȽϵ͵ÄSQL½øÐÐÓÅ»¯£¬Ê¹ÆäÔËÐÐЧÂʸü¸ß£¬ÆäÖÐÒªÇó¶ÔSQLÖеIJ¿·Öin/not inÐÞ¸ÄΪexists/not exists
Ð޸ķ½·¨ÈçÏ£º
inµÄSQLÓï¾ä
SELECT id, category_id, htmlfile, title, convert(varchar(20),begintime,112) as pubtime
from tab_oa_pub WHERE ......
String strServerName = "·þÎñÆ÷Ãû»òIP";
String strUserID = "Êý¾Ý¿âÓû§Ãû";
String strPSW= "Êý¾Ý¿âÃÜÂë";
DataTable DBNameTable = new DataTable();
OleDbConnection Connection = new OleDbConnection(String.Format("Provider=SQLOLEDB;Data Source={0};User ID={1};PWD={2}", strServerName, strUserID, strPS ......