SQLÓÅ»¯¼°UNION ALLÌæ´úUNION
OracleÓкܶàÖµµÃѧϰµÄµØ·½£¬ÕâÀïÎÒÃÇÖ÷Òª½éÉÜOracle UNION ALL£¬°üÀ¨½éÉÜUNIONµÈ·½Ã档ͨ³£Çé¿öÏ£¬ÓÃUNIONÌæ»»WHERE×Ó¾äÖеÄOR½«»áÆ𵽽ϺõÄЧ¹û¡£¶ÔË÷ÒýÁÐʹÓÃOR½«Ôì³ÉÈ«±íɨÃè¡£×¢Ò⣬ÒÔÉϹæÔòÖ»Õë¶Ô¶à¸öË÷ÒýÁÐÓÐЧ¡£¼ÙÈçÓÐcolumnûÓб»Ë÷Òý£¬²éѯЧÂÊ¿ÉÄÜ»áÒòΪÄúûÓÐÑ¡ÔñOR¶ø½µµÍ¡£ÔÚÏÂÃæµÄÀý×ÓÖУ¬LOC_ID ºÍREGIONÉ϶¼½¨ÓÐË÷Òý¡£
¸ßЧ£º
SELECT LOC_ID ¡£ LOC_DESC £¬REGION from LOCATION WHERE LOC_ID = 10 UNION SELECT LOC_ID £¬
LOC_DESC £¬REGION from LOCATION WHERE REGION = “MELBOURNE”
µÍЧ:
SELECT LOC_ID £¬LOC_DESC £¬REGION from LOCATION WHERE LOC_ID = 10 OR REGION = “MELBOURNE”
ÓÃINÀ´Ìæ»»OR£º
ÕâÊÇÒ»Ìõ¼òµ¥Ò׼ǵĹæÔò£¬µ«ÊÇʵ¼ÊµÄÖ´ÐÐЧ¹û»¹Ðë¼ìÑ飬ÔÚOracle8iÏ£¬Á½ÕßµÄÖ´Ðз¾¶ËƺõÊÇÏàͬµÄ:
µÍЧ:
SELECT…. from LOCATION WHERE LOC_ID = 10 OR LOC_ID = 20 OR LOC_ID = 30
¸ßЧ£º
SELECT… from LOCATION WHERE LOC_IN IN (10,20,30);
±ÜÃâÔÚË÷ÒýÁÐÉÏʹÓÃIS NULLºÍIS NOT NULL£º
±ÜÃâÔÚË÷ÒýÖÐʹÓÃÈκÎÄܹ»Îª¿ÕµÄÁУ¬Oracle½«ÎÞ·¨Ê¹ÓøÃË÷Òý¡£¶ÔÓÚµ¥ÁÐË÷Òý£¬¼ÙÈçÁаüº¬¿ÕÖµ£¬Ë÷ÒýÖн«²»´æÔڴ˼Ǽ¡£¶ÔÓÚ¸´ºÏË÷Òý£¬¼ÙÈçÿ¸öÁж¼Îª¿Õ£¬Ë÷ÒýÖÐͬÑù²»´æÔڴ˼Ǽ¡£¼ÙÈçÖÁÉÙÓÐÒ»¸öÁв»Îª¿Õ£¬Ôò¼Ç¼´æÔÚÓÚË÷ÒýÖС£¾ÙÀý£º¼ÙÈçΨһÐÔË÷Òý½¨Á¢ÔÚ±íµÄAÁкÍBÁÐÉÏ£¬²¢ÇÒ±íÖдæÔÚÒ»Ìõ¼Ç¼µÄ A£¬BֵΪ(123£¬null)£¬ Oracle½«²»½ÓÊÜÏÂÒ»Ìõ¾ß±¸ÏàͬA£¬BÖµ£¨123,null£©µÄ¼Ç¼(²åÈë)¡£È»¶ø¼ÙÈçÈκεÄË÷ÒýÁж¼Îª¿Õ£¬Oracle½«ÈÏΪÕû¸ö¼üֵΪ¿Õ¶ø¿Õ²»µÈÓÚ¿Õ¡£Òò´ËÄúÄܹ»²åÈë1000 Ìõ¾ß±¸Ïàͬ¼üÖµµÄ¼Ç¼,µ±È»ËûÃǶ¼ÊÇ¿Õ! ÒòΪ¿ÕÖµ²»´æÔÚÓÚË÷ÒýÁÐÖÐ,ËùÒÔWHERE×Ó¾äÖжÔË÷ÒýÁнøÐпÕÖµ±È½Ï½«Ê¹ORACLEÍ£ÓøÃË÷Òý¡£
×ÜÊÇʹÓÃË÷ÒýµÄµÚÒ»¸öÁУº
¼ÙÈçË÷ÒýÊǽ¨Á¢ÔÚ¶à¸öÁÐÉÏ£¬Ö»ÓÐÔÚËûµÄµÚÒ»¸öÁÐ(leading column)±»where×Ó¾äÒýÓÃʱ£¬ÓÅ»¯Æ÷²Å»áÑ¡ÔñʹÓøÃË÷Òý¡£ÕâÒ²ÊÇÒ»Ìõ¼òµ¥¶øÖØÒªµÄ¹æÔò£¬µ±½öÒýÓÃË÷ÒýµÄµÚ¶þ¸öÁÐʱ£¬ÓÅ»¯Æ÷ʹÓÃÁËÈ«±íɨÃè¶øºöÂÔÁËË÷Òý¡£
ÓÃOracle UNION ALLÌ
Ïà¹ØÎĵµ£º
use Dbname
go
select
[±íÃû]=c.Name,
[±í˵Ã÷]=isnull(f.[value],''),
[ÁÐÃû]=a.Name,
[ÁÐÐò號]=a.Column_id,
&nbs ......
×î½üÔÚ×öÒ»¸ö×¢²á³ÌÐò£¬µÃÓõÃÃÜÂëµÄMD5¼ÓÃÜ£¬Ö±½ÓÔÚ´æ´¢¹ý³ÌÖнøÐÐ×¢²á¡£
²éÕҵõ½£¬¿ÉÓÃÒÔÏ·½·¨½øÐмÓÃÜ£º
print RIGHT(sys.fn_VarBinToHexStr(hashbytes('MD5','ANSEN')),32)
Êý¾Ý¿âÊÇÓÃSQL SERVER 2005£¬ÆäËûµÄÊý¾Ý¿âÓ¦¸ÃÒ²²î²»µ½ÄÄÈ¥~~ ......
ת×Ô£ºhttp://news.newhua.com/news1/program_database/2008/530/0853093226E2KJ93C02415FEB1CD9A5HCKA821556279EEKJ7728GI5.html
ÊÂÎñÈÕÖ¾ÎļþTransaction Log FileÊÇÓÃÀ´¼Ç¼Êý¾Ý¿â¸üÐÂÇé¿öµÄÎļþ£¬À©Õ¹ÃûΪldf¡£
ÔÚ SQL Server 7.0 ºÍ SQL Server 2000 ÖУ¬Èç¹ûÉèÖÃÁË×Ô¶¯Ôö³¤¹¦ÄÜ£¬ÊÂÎñÈÕÖ¾Îļþ½«»á×Ô¶¯À©Õ¹¡£
Ò»° ......
ÏÂÁÐÓï¾ä²¿·ÖÊÇMssqlÓï¾ä£¬²»¿ÉÒÔÔÚaccessÖÐʹÓá£
SQL·ÖÀࣺ
DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
DML—Êý¾Ý²Ù×ÝÓïÑÔ(SELECT£¬DELETE£¬UPDATE£¬INSERT)
DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
CREATE DATABASE data ......
50¸ö³£ÓÃsqlÓï¾ä
Student(S#,Sname,Sage,Ssex) ѧÉú±í
Course(C#,Cname,T#) ¿Î³Ì±í
SC(S#,C#,score) ³É¼¨±í
Teacher(T#,Tname) ½Ìʦ±í
ÎÊÌ⣺
1¡¢²éѯ“001”¿Î³Ì±È“002”¿Î³Ì³É¼¨¸ßµÄËùÓÐѧÉúµÄѧºÅ;
select a.S# from (select s#,score from SC where C#='001') a,(select s#,sc ......