how things work : sql select statement
ÔÍøÕ¾ÎÞ·¨·ÃÎÊ£¬¹Ê±£Áôgoogle¿ìÕÕ
How things work :
SQL
Select
Statement
Introduction
:
Ever asked your self how things work inside the
SQL
Select
statement? In this article we won’t be talking about how to writeSQL
Select
statement but rather we will be talking about the algorithms and the methodology behind the
Select
statement and how
SQL
decides which
algorithm
it will use to filter out the results and return our expected results.
Selecting an
Algorithm
:
In fact you can’t do so, it is up to the
SQL
Optimizer implementation to determine the selected
algorithm
that best match the query you are going to invoke in order to enhance the query performance or in other words Optimize it, so you don’t have control over selecting the
algorithm
although some
SQL
Optimizer implementations tried to enable the DB Admin to specify which selection
algorithm
is suitable based on the admin knowledge (for example the admin might know that binary search –we will mentioned that latter- might be the best choice).
The Preparation:
We need to get prepared first and get familiar with the terminologies that we will be using through the article
Before we go further we need to know the types of indexes:
• Primary index – allows records to be read in an order that corresponds to the physical order in the file.
• Secondary index – any index that is not a primary index.
When we make an index we create something like a database for Indexing except it only include the key being indexed and the location counter which holds the location on the record in the database itself (the one that contains the data).
Access path: An access path is an
algorithm
used by Database to satisfy the requirements of
SQL
statements.
Ïà¹ØÎĵµ£º
TABLE MASTER ×ֶΠID DETAIL.....
TABLE BIZ ×ֶΠSYS_ID CODE_ID .......
²éѯʱÐèÒªµÄÊÇIDµÄÃèÊö
1,SELECT A.SYS_ID,A.CODE_ID,B.DETAIL,C.DETAIL...... from BIZ A,MASTER B,MASTER C WHERE A.SYS_ID=B.ID AND A.CODE_ID=C.ID
2,SELECT SYS_ID,(SELECT DETAIL from MASTER ......
alter table ±íÃû
add constraint Ô¼ÊøÃû
foreign key(×Ö¶ÎÃû) references Ö÷±íÃû(×Ö¶ÎÃû)
on delete cascade
Óï·¨£º
Foreign Key
(column[,...n])
references referenced_table_name[(ref_column[,...n])]
[on delete cascade]
[on update cascade]
×¢ÊÍ£º
column:ÁÐÃû
referenced_table_name:Íâ¼ü²Î¿¼µÄÖ÷¼ü± ......
*
sql xml ÈëÃÅ:
--by jinjazz
--http://blog.csdn.net/jinjazz
1¡¢xml: ÄÜÈÏʶԪËØ¡¢ÊôÐÔºÍÖµ
2¡¢xpath: Ñ°Ö·ÓïÑÔ£¬ÀàËÆwind ......
for ACCESS :
update a, b set a.name=b.name1 where a.id=b.id
for SQL Server:
"update a set a.name=b.name1 from a,b where a.id=b.id"
update a set a.status=b.status
from table1 a,table2 b
&nbs ......
¶ÔSQL Server 2008 ½øÐÐMirrorµÄ»ù±¾ÅäÖü°°²×°¡£
×¼±¸¹¤×÷
1. Principal ÓëMirror ÒÔ¼° Witness Èý̨ʵÀý¶¼°²×°ÎªÏàͬ°æ±¾£¬Ä¿Ç°Êǵ½SQL Server 2008 SP1¡£
2. ÐèÒªÓÐÒ»¸öÓòÕÊ»§·Ö±ðÌí¼Óµ½ Èý̨Êý¾Ý¿âʵÀýËùÔÚµÄServer µÄ Administrators×é¡¢ÒÔ¼°SQL Server Ïà¹ØµÄ×éÖУ» ÓÉÓÚ¾ßÌåµÄ×éµÄ¹¦Äܲ»Çå³þ£¬Òò´Ë½¨ÒéËùÓ ......