Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

CASEÔÚsql serverÖеÄʹÓÃÓ÷¨

CASE Óï¾äÔÚsql server¸úÆäËü³ÌÐòÓïÑÔÖеÄswitch¹¦ÄÜÀàËÆ£¬ÓÃÓÚ¼ÆËãÌõ¼þÁÐ±í²¢·µ»Ø¶à¸ö¿ÉÄܽá¹û±í´ïʽ֮һ¡£
ÔÚsql serverÖÐCASE¾ßÓÐÁ½ÖÖ¸ñʽ£º
a.¼òµ¥ CASE º¯Êý½«Ä³¸ö±í´ïʽÓëÒ»×é¼òµ¥±í´ïʽ½øÐбȽÏÒÔÈ·¶¨½á¹û¡£
b.CASE ËÑË÷º¯Êý¼ÆËãÒ»×é²¼¶û±í´ïʽÒÔÈ·¶¨½á¹û¡£
ÒÔÉÏÁ½ÖÖ¸ñʽ¶¼Ö§³Ö¿ÉÑ¡µÄ ELSE ²ÎÊý¡£
³£¼ûµÄ¼¸ÖÖCASEÓï¾äµÄÓ÷¨ÈçÏÂËùʾ:
   1.CASE º¯ÊýÓÃÓÚ¼ÆËã¶à¸öÌõ¼þ²¢ÎªÃ¿¸öÌõ¼þ·µ»Øµ¥¸öÖµ¡£CASE º¯Êýͨ³£µÄÓÃ;ÊÇʹÓÿɶÁÐÔ¸üÇ¿µÄÖµÌæ»»´úÂë»òËõд¡£
ÏÂÃæµÄ²éѯʹÓà CASE º¯ÊýÖØÃüÃûÊé¼®µÄ·ÖÀ࣬ÒÔʹ֮¸üÒ×Àí½â¡£
USE pubs
SELECT
   CASE type
      WHEN 'popular_comp' THEN 'Popular Computing'
      WHEN 'mod_cook' THEN 'Modern Cooking'
      WHEN 'business' THEN 'Business'
      WHEN 'psychology' THEN 'Psychology'
      WHEN 'trad_cook' THEN 'Traditional Cooking'
      ELSE 'Not yet categorized'
   END AS Category,
CONVERT(varchar(30), title) AS "Shortened Title",
price AS Price
from titles
WHERE price IS NOT NULL
ORDER BY 1
    2.ʹÓôøÓмòµ¥ CASE º¯ÊýºÍ CASE ËÑË÷º¯ÊýµÄ SELECT Óï¾ä
    CASE º¯ÊýµÄÁíÒ»¸öÓÃ;¸øÊý¾Ý·ÖÀà¡£ÏÂÃæµÄ²éѯʹÓà CASE º¯Êý¶Ô¼Û¸ñ·ÖÀà¡£
SELECT
   CASE
      WHEN price IS NULL THEN 'Not yet priced'
      WHEN price < 10 THEN 'Very Reasonable Title'
      WHEN price >= 10 and price < 20 THEN 'Coffee Table Title'
      ELSE 'Expensive book!'
   END AS "Price Category",
CONVERT(varchar(20), title) AS "Shortened Title"
from pubs.dbo.titles
ORDER BY price
    3.ʹÓôøÓÐ SUBSTRING ºÍ SELECT µÄ CASE º¯Êý
ÏÂÃæµÄʾÀýʹÓà CASE ºÍ THEN Éú³ÉÒ»¸öÓйØ×÷Õß¡¢Í¼Êé±êʶºÅºÍÿ¸ö×÷ÕßËùÖøͼÊéÀàÐ͵ÄÁÐ±í¡£
USE pubs
SELECT SUBSTRING((RTRIM(a.au_fname) + ' '+
   RTRIM(a.au_lname) + ' '), 1, 25) AS Name, a


Ïà¹ØÎĵµ£º

[ÊÕ£] ÓÃsqlite Ö´Ðбê×¼ sql Óï·¨

http://www.umgr.com/blog/PostView.aspx?bpId=36294
 1. Ö´ÐÐsqlÓï¾ä
int sqlite3_exec(sqlite3*£¬ const char *sql£¬ sqlite3_callbacksql Óï·¨
£¬ void *£¬  char **errmsg );
Õâ¾ÍÊÇÖ´ÐÐÒ»Ìõ sql Óï¾äµÄº¯Êý¡£
µÚ1¸ö²ÎÊý²»ÔÙ˵ÁË£¬ÊÇÇ°Ãæopenº¯ÊýµÃµ½µÄÖ¸Õ롣˵ÁËÊǹؼüÊý¾Ý½á¹¹¡£
µÚ2¸ö²ÎÊýconst char ......

Oracleά»¤³£ÓÃ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¡¢²é¿´±í¿Õ¼äÎïÀíÎļþµÄÃû³Æ¼°´óС
¡¡¡¡select tablesp ......

SQL Server´æ´¢¹ý³ÌµÄÃüÃû±ê×¼


ÔÚ±¾ÎÄÖУ¬´ËʾÀý±ê×¼À¶Í¼µÄ´æ´¢¹ý³ÌÃüÃû·½·¨Ö»ÊÊÓÃÓÚSQLÄÚ²¿£¬¼ÙÈçÄãÕýÔÚ´´½¨Ò»¸öеĴ洢¹ý³Ì£¬»òÊÇ·¢ÏÖÒ»¸öûÓа´ÕÕÕâ¸ö±ê×¼¹¹ÔìµÄ´æ´¢¹ý³Ì£¬¼´¿ÉÒԲο¼Ê¹ÓÃÕâ¸ö±ê×¼¡£
×¢ÊÍ£º¼ÙÈç´æ´¢¹ý³ÌÒÔsp_ Ϊǰ׺¿ªÊ¼ÃüÃûÄÇô»áÔËÐеÄÉÔ΢µÄ»ºÂý£¬ÕâÊÇÒòΪSQL Server½«Ê×ÏȲéÕÒϵͳ´æ´¢¹ý³Ì£¬ËùÒÔÎÒÃǾö²»ÍƼöʹÓÃsp_×÷Ϊǰ׺¡ ......

oracle sql×Ô¶¯µÝÔö

Ò»¡¢É¾³ýÁÐ
ALTER TABLE AA DROP COLUMN  DEP;
ÊÊÓÃÓÚС±í-----Êý¾ÝÁ¿Ð¡µÄʱºò£»
2¡¢ALTER TABLE AA SET UNUSED("DEP") CASCADE CONSTRAINTS;
È»ºóÔÚ¸ºÔØСµÄʱºò£¬É¾³ý
ALTER TABLE AA DROP UNUSED COLUMNS;
¶þ¡¢Ìí¼ÓÁÐ
ÏȼÓÒ»ÐÂ×Ö¶ÎÔÙ¸³Öµ£º
alter table table_name add mmm  varchar2(10);
update ta ......

SQLÐÔÄܵ÷УÃüÁî

DBCC DROPCLEANBUFFERS  --Çå³ý»º³åÇø£¬±ãÓڶԱȲéѯʱ¼äºÍÐÔÄÜ£¬²»ÊÕ»º´æµÄÓ°Ïì
SET STATISTICS TIME  ON --ÏÔʾ·ÖÎö¡¢±àÒëºÍÖ´Ðи÷Óï¾äËùÐèµÄºÁÃëÊý
sp_spaceused NSDoctorAdvice0705 -- ²é¿´±í¿Õ¼ä´óС
ÎÊÌâÌÖÂÛ£º
ÊÇ·ñÔö¼ÓÒ»¸ö¶ÀÁ¢µÄÎļþ×飬ÓÃÀ´´æ·ÅË÷Òý¡£Ä¿Ç°Êý¾Ý¿âµÄÖ»ÓÐÒ»¸öÎļþ×飬Îļþ·Ç³£´óµÄ»°£¬ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ