7. 7
C但u l畛nh SQL
Insert
Copy t畛 1 b畉ng sang 1 b畉ng kh叩c
Select * into t棚nBangMoi
From t棚nBang1
Select cotK1, cotK2, into t棚nBangMoi
From t棚nBang1, t棚nBang2,
Where
Group By
Ho畉t 畛ng:
T畉o b畉ng t棚nBangMoi
Ch辿p d畛 li畛u vo t棚nBangMoi
8. 8
C但u l畛nh SQL
Update
C但u l畛nh Update d湛ng 畛 c畉p nh畉t (ch畛nh s畛a)
d畛 li畛u
Update t棚nBang
Set cot1=newValue1, , cotN=newValueN
Where cot1 = oldValue1 and and cotN=oldValueN
畛 x坦a gi叩 tr畛 c畛a 1 担 d畛 li畛u trong b畉ng,
ch炭ng ta thi畉t l畉p gi叩 tr畛 坦 b畉ng null
Update t棚nBang
Set cot1=null,
Where cotA = oldValueA
9. 9
C但u l畛nh SQL
Delete
C但u l畛nh Delete d湛ng 畛 x坦a 1 s畛 d嘆ng d畛
li畛u trong b畉ng
Delete From t棚nBang
Where cot1=giatri1 and cot2=giatri2 and and
cotN=giatriN
Ch炭 箪:
Delete d湛ng 畛 x坦a c畉 1 d嘆ng, ch畛 kh担ng x坦a 1
c畛t c畛a d嘆ng
Delete kh担ng x坦a b畉ng, ch畛 x坦a d畛 li畛u
畛 x坦a m畛i d嘆ng d畛 li畛u trong b畉ng n棚n d湛ng
l畛nh Truncate Table
T畛 kh坦a From trong c但u l畛nh delete c坦 th畛 b畛,
nh動ng kh担ng n棚n b畛
27. 27
Ch畛nh s畛a d畛 li畛u Disconnected
Phi棚n b畉n d畛 li畛u trong DataRow
C叩c gi叩 tr畛 trong enum DataRowVersion
Current - L畉y gi叩 tr畛 hi畛n tai
Original - L畉y gi叩 tr畛 g畛c
Proposed - L畉y gi叩 tr畛 sau BeginEdit v
tr動畛c EndEdit
Default - L畉y gi叩 tr畛 nh動 khi tham s畛 ny
ch畛 ra
#5: Although this syntax is indeed simple, it is not at all safe and should generally be avoided at all costs. The above SQL statement is highly dependent on the order in which the columns are defined in the table. It also depends on information about that order being readily available. Even if it is available, there is no guarantee that the columns will be in the exact same order the next time the table is reconstructed. Therefore, writing SQL statements that depend on specific column ordering is very unsafe. If you do so, something will inevitably break at some point.
#9: UPDATE Customers SET cust_email = 'kim@thetoystore.com' WHERE cust_id = '1000000005'; The UPDATE statement always begins with the name of the table being updated. In this example, it is the Customers table. The SET command is then used to assign the new value to a column. As used here, the SET clause sets the cust_email column to the specified value:
SET cust_email = 'kim@thetoystore.com' The UPDATE statement finishes with a WHERE clause that tells the DBMS which row to update. Without a WHERE clause, the DBMS would update all the rows in the Customers table with this new email addressdefinitely not the desired effect.
#10: From trong delete l option nh動ng nen dung n坦
Faster Deletes If you really do want to delete all rows from a table, don't use DELETE. Instead, use the TRUNCATE TABLE statement which accomplished the same thing but does it much quicker (because data changes are not logged).
#21: Detached: D嘆ng 達 t畉o nh動ng ch動a th棚m vo Table
Detached The row has been created but is not part of any DataRowCollection. A DataRow is in this state immediately after it has been created and before it is added to a collection, or if it has been removed from a collection.
Unchanged The row has not changed since AcceptChanges was last called.
Added The row has been added to a DataRowCollection, and AcceptChanges has not been called.
Deleted The row was deleted using the Delete method of the DataRow.
Modified The row has been modified and AcceptChanges has not been called.