DBMS ไทย บทที่ 07...
description
Transcript of DBMS ไทย บทที่ 07...
7 Transact-SQL
7 Transact-SQL
3 Data Structure Integrity Rule Entity Integrity Referential Integrity
Data Structure Integrity Rule
SQL 2 DML (Data Manipulation Language) SELECT, INSERT, UPDATE, DELETE DDL (Data Definition Language) CREATE, ALTER, DROP, GRANT, REVOKE
SQL DML Transact-SQL SELECT SELECT
SELECT SELECT SELECT
SELECT select_list
[INTO new_table]
FROM table_source
[WHERE search_condition]
[GROUP BY group_by_expression]
[HAVING search_condition]
[ORDER BY order_expression[ASC | DESC]]
SELECT 2 SELECT SELECT SELECT FROM SELECT FROM WHERE Note
SELECT ( ) SELECT SELECT
SELECT FROM SELECT , CustomerID, CustomerName, CustomerAddress TblCustomers
Note
SELECT * SELECT
OrderID TblOrders TblOrderDetails
SELECT FROM TOP n [Percent] n Percent n SELECT
OrderID TOP % 5% OrderID TOP 5
DISTINCT
SELECT SELECT SELECT SELECT SELECT DISTINCT
SELECT OrderID
SELECT As ,[n] From
OrderID Product Count Tbl OrderDetails Sum Of Product
Note
Transact-SQL , , [] Sum Of Product [Sum Of Product], Sum Of Product Sum Of Product Transact-SQL
SELECT
SELECT TblProducts TblOrderDetails TP TOD
SELECT FROM WHERE WHERE search_condition
WHERE ProductName UnitPrice TblProducts Unitprice () 400 700
search_codition UnitPrice 400 700 WHERE 2 AND UnitPrice>400 UnitPrice , ! =
> , >= =
!>
< ,< = =
!