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

sql serverÊÓͼµÄ×÷ÓÃ

 ÊÓͼ¿ÉÒÔ±»¿´³ÉÊÇÐéÄâ±í»ò´æ´¢²éѯ¡£¿Éͨ¹ýÊÓͼ·ÃÎʵÄÊý¾Ý²»×÷Ϊ¶ÀÌصĶÔÏó´æ´¢ÔÚÊý¾Ý¿âÄÚ¡£Êý¾Ý¿âÄÚ´æ´¢µÄÊÇ SELECT Óï¾ä¡£SELECT Óï¾äµÄ½á¹û¼¯¹¹³ÉÊÓͼËù·µ»ØµÄÐéÄâ±í¡£Óû§¿ÉÒÔÓÃÒýÓñíʱËùʹÓõķ½·¨£¬ÔÚ Transact-SQL Óï¾äÖÐͨ¹ýÒýÓÃÊÓͼÃû³ÆÀ´Ê¹ÓÃÐéÄâ±í¡£Ê¹ÓÃÊÓͼ¿ÉÒÔʵÏÖÏÂÁÐÈÎÒ»»òËùÓй¦ÄÜ£º
½«Óû§ÏÞ¶¨ÔÚ±íÖеÄÌض¨ÐÐÉÏ¡£
ÀýÈ磬ֻÔÊÐí¹ÍÔ±¿´¼û¹¤×÷¸ú×Ù±íÄڼǼÆ乤×÷µÄÐС£
½«Óû§ÏÞ¶¨ÔÚÌض¨ÁÐÉÏ¡£
ÀýÈ磬¶ÔÓÚÄÇЩ²»¸ºÔð´¦Àí¹¤×ʵ¥µÄ¹ÍÔ±£¬Ö»ÔÊÐíËûÃÇ¿´¼û¹ÍÔ±±íÖеÄÐÕÃûÁС¢°ì¹«ÊÒÁС¢¹¤×÷µç»°ÁкͲ¿ÃÅÁУ¬¶ø²»ÄÜ¿´¼ûÈκΰüº¬¹¤×ÊÐÅÏ¢»ò¸öÈËÐÅÏ¢µÄÁС£
½«¶à¸ö±íÖеÄÁÐÁª½ÓÆðÀ´£¬Ê¹ËüÃÇ¿´ÆðÀ´ÏóÒ»¸ö±í¡£
¾ÛºÏÐÅÏ¢¶ø·ÇÌṩÏêϸÐÅÏ¢¡£
ÀýÈ磬ÏÔʾһ¸öÁеĺͣ¬»òÁеÄ×î´óÖµºÍ×îСֵ¡£
ͨ¹ý¶¨Òå SELECT Óï¾äÒÔ¼ìË÷½«ÔÚÊÓͼÖÐÏÔʾµÄÊý¾ÝÀ´´´½¨ÊÓͼ¡£SELECT Óï¾äÒýÓõÄÊý¾Ý±í³ÆΪÊÓͼµÄ»ù±í¡£ÔÚÏÂÀýÖУ¬pubs Êý¾Ý¿âÖÐµÄ titleview ÊÇÒ»¸öÊÓͼ£¬¸ÃÊÓͼѡÔñÈý¸ö»ù±íÖеÄÊý¾ÝÀ´ÏÔʾ°üº¬³£ÓÃÊý¾ÝµÄÐéÄâ±í£º
CREATE VIEW titleview
AS
SELECT title, au_ord, au_lname, price, ytd_sales, pub_id
from authors AS a
JOIN titleauthor AS ta ON (a.au_id = ta.au_id)
JOIN titles AS t ON (t.title_id = ta.title_id)
Ö®ºó£¬¿ÉÒÔÓÃÒýÓñíʱËùʹÓõķ½·¨ÔÚÓï¾äÖÐÒýÓà titleview¡£
SELECT *
from titleview
Ò»¸öÊÓͼ¿ÉÒÔÒýÓÃÁíÒ»¸öÊÓͼ¡£ÀýÈ磬titleview ÏÔʾµÄÐÅÏ¢¶Ô¹ÜÀíÈËÔ±ºÜÓÐÓ㬵«¹«Ë¾Í¨³£Ö»ÔÚ¼¾¶È»òÄê¶È²ÆÎñ±¨±íÖвŹ«²¼±¾Äê¶È½ØÖ¹µ½ÏÖÔڵIJÆÕþÊý×Ö¡£¿ÉÒÔ½¨Á¢Ò»¸öÊÓͼ£¬ÔÚÆäÖаüº¬³ý au_ord ºÍ ytd_sales ÍâµÄËùÓÐ titleview ÁС£Ê¹ÓÃÕâ¸öÐÂÊÓͼ£¬¿Í»§¿ÉÒÔ»ñµÃÒÑÉÏÊеÄÊé¼®Áбí¶ø²»»á¿´µ½²ÆÎñÐÅÏ¢£º
CREATE VIEW Cust_titleview
AS
SELECT title, au_lname, price, pub_id
from titleview
ÊÓͼ¿ÉÓÃÓÚÔÚ¶à¸öÊý¾Ý¿â»ò Microsoft® SQL Server™ 2000 ʵÀý¼ä¶ÔÊý¾Ý½øÐзÖÇø¡£·ÖÇøÊÓͼ¿ÉÓÃÓÚÔÚÕû¸ö·þÎñÆ÷×éÄÚ·Ö²¼Êý¾Ý¿â´¦Àí¡£·þÎñÆ÷×é¾ßÓÐÓë·þÎñÆ÷¾Û¼¯ÏàͬµÄÐÔÄÜÓŵ㣬²¢¿ÉÓÃÓÚÖ§³Ö×î´óµÄ Web Õ¾µã»ò¹«Ë¾Êý¾ÝÖÐÐĵĴ¦ÀíÐèÇó¡£Ô­Ê¼±í±»Ï¸·ÖΪ¶à¸ö³ÉÔ±±í£¬Ã¿¸ö³ÉÔ±±í°üº¬Ô­Ê¼±íµÄÐÐ×Ó¼¯¡£Ã¿¸ö³ÉÔ±±í¿É·ÅÖÃÔÚ²»Í¬·þÎñÆ÷µÄÊý¾Ý¿âÖС£Ã¿¸ö·þÎñÆ÷Ò²¿ÉµÃµ½·ÖÇøÊÓͼ¡£·ÖÇøÊÓͼʹÓà Transact-SQL UNION ÔËËã·û£¬½«ÔÚËùÓгÉÔ±±íÉÏÑ¡ÔñµÄ½á¹ûºÏ²¢Îªµ¥¸ö½á¹û¼¯£¬¸Ã½á¹û¼¯µÄÐÐΪÓëÕû¸öԭʼ±íµÄ¸´±¾ÍêÈ«Ò»Ñù¡£ÀýÈçÔÚÈý¸


Ïà¹ØÎĵµ£º

sql²éѯ±íÖÐ×ֶβ»Öظ´

·½·¨Ò»£º
 select distinct name from tablename
·½·¨¶þ£º
select min(fid),name,sex from tablename group by name
×ܼƣº
select distinct name from tablename ´ò¿ªÖظ´¼Ç¼µÄµ¥¸ö×Ö¶Î
select * from tablename where fid in(Select min(fid) from tablename group by name)´ò¿ªÖظ´¼Ç¼µÄËùÓÐ×Ö¶ÎÖµ
select ......

SQL ServerºÍOracleµÄ³£Óú¯Êý¶Ô±È

---------Êýѧº¯Êý
1.¾ø¶ÔÖµ
S:select abs(-1) value
O:select abs(-1) value from dual
2.È¡Õû(´ó)
S:select ceiling(-1.001) value
O:select ceil(-1.001) value from dual
3.È¡Õû£¨Ð¡£©
S:select floor(-1.001) value
O:select floor(-1.001) value from dual
4.È¡Õû£¨½ØÈ¡£©
S:select cast(-1.002 as int) v ......

SQLÁ¬½Ó·ÖÀ༰ʹÓÃ˵Ã÷

 Í¨¹ýÁ¬½ÓÔËËã·û¿ÉÒÔʵÏÖ¶à¸ö±í²éѯ¡£Á¬½ÓÊǹØϵÊý¾Ý¿âÄ£Ð͵ÄÖ÷ÒªÌص㣬ҲÊÇËüÇø±ðÓÚÆäËüÀàÐÍ
Êý¾Ý¿â¹ÜÀíϵͳµÄÒ»¸ö±êÖ¾¡£
ÔÚ¹ØϵÊý¾Ý¿â¹ÜÀíϵͳÖУ¬±í½¨Á¢Ê±¸÷Êý¾ÝÖ®¼äµÄ¹Øϵ²»±ØÈ·¶¨£¬³£°ÑÒ»¸öʵÌåµÄËùÓÐÐÅÏ¢´æ·ÅÔÚ
Ò»¸ö±íÖС£µ±¼ìË÷Êý¾Ýʱ£¬Í¨¹ýÁ¬½Ó²Ù×÷²éѯ³ö´æ·ÅÔÚ¶à¸ö±íÖеIJ»Í¬ÊµÌåµÄÐÅÏ¢¡£Á¬½Ó²Ù×÷¸øÓû ......

DBA³£ÓÃsql(¶þ)

 session״̬£º
STATUS VARCHAR2(8) Status of the session:
ACTIVE - Session currently executing SQL
INACTIVE - sql¼°ÆäsessionûÓÐÊÍ·Å»òÕý³£Í˳ö......
KILLED - Session marked to be killed
CACHED - Session temporarily cached for use by Oracle*XA
SNIPED - Session inactive, waiting on the clie ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ