SQL SERCER ±í×Ö¶ÎÐÞ¸Ä ×ܽá
ÕâÁ½ÌìÑо¿ÁËSQL SERVERµÄ×Ö¶ÎÐÞ¸Ä.ÓÐһЩÐĵÃ,д³öÀ´ÎªÈÕºó²Î¿¼:
1,ɾ³ý×Ö¶Î: ALTER TABLE [tablename] DROP COLUMN [fieldname]
ɾ³ýµÄʱºò¸Ã×ֶαØÐëûÓб»ÈκÎÍâ¼üÒýÓÃ,ûÓÐÈκÎÔ¼Êø.
2,ɾ³ýÔ¼Êø: ALTER TABLE [tablename] DROP CONSTRAINT constraint_name
ɾ³ýÔ¼ÊøÊÇÔ¼ÊøÃû²»¿É¼Óµ¥ÒýºÅ.
3,Ôö¼ÓĬÈÏÖµÔ¼Êø: ALTER TABLE [tablename] ADD CONSTRAINT constraint_name DEFAULT 'default_value' FOR [fieldname]
ÓÃFOR¹Ø¼ü×ÖÖ¸¶¨ÎªÄǸö×Ö¶ÎÔö¼ÓĬÈÏÖµÔ¼Êø.
4,ÐÞ¸Ä×Ö¶Î: ALTER TABLE [tablename] ALTER COLUMN [fieldname] new_datatype isnull
Òª¸ü¸ÄµÄÁÐµÄ new_data_type Ó¦·ûºÏÏÂÁÐ×¼Ôò£º
A,ÔÀ´µÄÊý¾ÝÀàÐͱØÐë¿ÉÒÔÒþʽת»»ÎªÐÂÊý¾ÝÀàÐÍ¡£(·¢ÏÖ,Èç¹ûÔÀ´µÄÊý¾ÝÀàÐÍÊÇtextµÄ¾ÍÔÙÒ²²»ÄÜÐÞ¸ÄÊý¾ÝÀàÐÍÁË)
B,new_data_type ÀàÐͲ»ÄÜΪ timestamp¡£
C,¶Ô ALTER COLUMN£¬ANSI ¿ÕĬÈÏֵʼÖÕ´ò¿ª£»Èç¹ûûÓÐÖ¸¶¨£¬Áн«¿ÉΪ¿Õ¡£
D,¶Ô ALTER COLUMN£¬ANSI Ìî³äʼÖÕ´ò¿ª¡£
E,Èç¹ûÒª¸ü¸ÄµÄÁÐÊDZêʶÁУ¬new_data_type ±ØÐëÊÇÖ§³Ö±êʶÊôÐÔµÄÊý¾ÝÀàÐÍ¡£
F,½«ºöÂÔSET ARITHABORTµÄµ±Ç°ÉèÖá£ALTER TABLEÓï¾äµÄÐÐΪÈçͬARITHABORTÑ¡ÏîΪONʱһÑù¡£
G,Ö»ÓÐÁÐÖв»°üº¬¿Õֵʱ£¬ALTER COLUMN ÖвſÉÖ¸¶¨ NOT NULL¡£
½«¿ÕÖµ¸üÐÂΪ·Ç¿ÕÖµ:UPDATE [tablename] SET [nullfield] = 'some_value' WHERE [nullfield] IS NULL
5£¬Ôö¼Ó´øĬÈÏÖµÔ¼ÊøµÄ×Ö¶Î:
ALTER TABLE [tablename] ADD [new_field_name] new_datatype isnull CONSTRAINT constraint_name DEFAULT 'default_value' WITH VALUES
A, 'WITH VALUES' ¿ÉÒÔ²»Ð´,дµÄ»°,¾ÍÓøÃDEFAULTÔ¼ÊøÖ¸¶¨µÄÖµ,Ìî³äÔÚËùÓÐÒÑÓмǼмӵÄ×Ö¶ÎÉÏ,·ñÔòʹÓÃ'NULL'Ìî³äÔÚËùÓÐÒÑÓмǼмӵÄ×Ö¶ÎÉÏ.
B, Ìí¼Óµ½±íÖеÄÐÂÁÐҪôÔÊÐí¿ÕÖµ£¬ÒªÃ´±ØÐëÖ¸¶¨Ä¬ÈÏÖµ¡£
6,ʹÓÃsp_rename´æ´¢¹ý³ÌÐÞ¸Ä×Ö¶ÎÃû³Æ:sp_rename @objname = '[tablename].[fieldname]' , @newname = 'newfieldname' ,@objtype = 'COLUMN'
²ÎÊýobjname±ØÐëÖ¸¶¨Îª[±íÃû].[ÓûÐ޸ĵÄ×Ö¶ÎÃû]ÕâÑùµÄÐÎʽ,ÒªÐÞ¸Ä×Ö¶ÎÃûµÄ»°objtype¾Í±ØÐëÖ¸¶¨Îª'COLUMN'.ÖµµÃ×¢ÒâµÄÊÇnewnameÕâ¸ö²ÎÊýÖеÄ×Ö¶ÎÃû²»¿ÉÒÔʹÓÃ"[]",µ«¿ÉÒÔÔÚÆäÖÐʹÓÿոñ,²»¹ýÔÚÒÔºóʹÓÃÕâ¸ö×Ö¶ÎÃûʱҪΪÆä¼ÓÉÏ"[]",Èç¹û²»Ð¡ÐÄʹÓÃ"[]"µÄ»°×Ö¶ÎÃû³Æ»á±»Ð޸ijÉ[[newfieldname]]]ÕâÑùµÄ¹ÖÑù×ÓµÄ.Õâ¸öÒ»¶¨Òª¼ÇסÁË!
Ïà¹ØÎĵµ£º
ϵͳ»·¾³£ºWindows 7
Èí¼þ»·¾³£ºVisual C++ 2008 SP1 +SQL Server 2005
±¾´ÎÄ¿µÄ£º±àдһ¸öº½¿Õ¹ÜÀíϵͳ
ÕâÊÇÊý¾Ý¿â¿Î³ÌÉè¼ÆµÄ³É¹û£¬ËäÈ»³É¼¨²»¼Ñ£¬µ«ÊÇ×÷ΪÎÒÓÃVC++ ÒÔÀ´±àдµÄ×î´ó³ÌÐò»¹ÊÇ´«µ½ÍøÉÏ£¬ÒÔ¹©²Î¿¼¡£ÓÃVC++ ×öÊý¾Ý¿âÉè¼Æ²¢²»ÈÝÒ×£¬µ«Ò²²»ÊDz»¿ÉÄÜ¡£ÒÔÏÂÊÇÎҵijÌÐò½çÃ棬ºóÃæ ......
µÚÒ»Ìõ£º
select * from where field in (1,2,3) ÕâÖÖд·¨Ó¦¸ÃÉáÆúÁË£¬¶øÓ¦¸ÃÕâÑùд£º
select * from table where field = 1 or field = 2 or field = 3
ΪʲôÄØ£¿
·²ÊÂÖ»ÓÐ×ö¹ý²ÅÖªµÀ£¬×Ô¼º½¨¸ö±í£¬²åÈë10WÌõ²âÊÔÊý¾Ý£¬ÓÃsql²âÊÔһϱãÖª£¬ÒòΪ¹¤×÷±ãÀû£¬ÎÒÔÚ²úÆ·»úºÍÍâÍø²âÊÔ»ú¶¼ÒѾ²âÊÔ¹ý£ ......
˵µ½Èí½âÎö£¨soft prase
£©ºÍÓ²½âÎö£¨
hard prase
£©£¬¾Í²»Äܲ»ËµÒ»ÏÂ
Oracle
¶Ô
sql
µÄ´¦Àí¹ý³Ì¡£µ±Äã·¢³öÒ»Ìõ
sql
Óï¾ä½»¸¶
Oracle
£¬ÔÚÖ´ÐкͻñÈ¡½á¹ûÇ°£¬
Oracle
¶Ô´Ë
sql
½«½øÐм¸¸ö²½ÖèµÄ´¦Àí¹ý³Ì£º
1¡¢Óï·¨¼ì²é£¨
syntax check
£©
&nb ......
Five basic search conditions are summarized here:
1) Comparison test
2) Range test
3) Set membership test
4) Pattern matching test (Like)
The pattern matching test checks to see whether the data value in a column matches a specified pattern
% mathes any se ......
±ÜÃâSQL×¢ÈëµÄ·½·¨ÓÐÁ½ÖÖ£ºÒ»ÊÇËùÓеÄSQLÓï¾ä¶¼´æ·ÅÔÚ´æ´¢¹ý³ÌÖУ¬ÕâÑù²»µ«¿ÉÒÔ±ÜÃâSQL×¢È룬»¹ÄÜÌá¸ßһЩÐÔÄÜ£¬²¢ÇÒ´æ´¢¹ý³Ì¿ÉÒÔÓÉרÃŵÄÊý¾Ý¿â¹ÜÀíÔ±(DBA)±àдºÍ¼¯ÖйÜÀí£¨ÕâÖÖ×ö·¨ÎÒÔÚһЩ¹«Ë¾¼û¹ý£©£¬²»¹ýÕâÖÖ×ö·¨ÓÐʱºòÕë¶ÔÏàͬµÄ¼¸¸ö±íÓв»Í¬Ìõ¼þµÄ²éѯ£¬SQLÓï¾ä¿ÉÄܲ»Í¬£¬ÕâÑù¾Í»á±àд´óÁ¿µÄ´æ´¢¹ý³Ì£¬ËùÒÔÓÐÈËÌá³ ......