根據SQL Anywhere User
SELECT語句
SELECT *
FROM employee
SELECT *
FROM employee
ORDER BY emp_lname ASC
SELECT *
FROM employee
ORDER BY emp_lname DESC
SELECT emp_lname
FROM employee
SELECT *
FROM employee
WHERE emp_fname=
(一定使用單引號)
SELECT emp_fname
FROM employee
WHERE emp_fname =
ORDER BY birth_date
SELECT emp_lname
FROM employee
WHERE birth_date <
(=
SELECT emp_lname
FROM employee
WHERE emp_lname LIKE
(%
SELECT emp_lname
FROM employee
WHERE SOUNDEX( emp_lname ) = SOUNDEX(
(找出英文中發音相同的記錄
SELECT emp_lname
FROM employee
WHERE birth_date BETWEEN
SELECT emp_lname
FROM employee
WHERE emp_lname IN (
連接表
SELECT *
FROM sales_order
WHERE sales_order
SELECT E
FROM sales_order as S
WHERE S
ORDER BY E
連接兩表的快捷鍵
SELECT emp_lname
FROM sales_order
KEY JOIN employee
(主鍵與外部鍵對應的地方
SELECT company_name
CAST( SUM(sales_order_items
FROM customer
KEY JOIN sales_order
KEY JOIN sales_order_items
KEY JOIN product
GROUP BY company_name
SELECT emp_lname
FROM employee
NATURAL JOIN department
(找出兩表間有相同的字段名
集合
SELECT count( * )
FROM employee
SELECT count( * )
min( birth_date )
max( birth_date )
FROM employee
(MIN
SELECT sales_rep
FROM sales_order
GROUP BY sales_rep
(在使用GROUP BY時
SELECT sales_rep
FROM sales_order
KEY JOIN employee
GROUP BY sales_rep
HAVING count( * ) >
更新數據庫
INSERT
INTO department ( dept_id
VALUES (
INSERT
INTO department
VALUES (
UPDATE employee
SET dept_id =
WHERE emp_id =
DELETE
FROM employee
WHERE termination_date IS NOT NULL
DELETE
FROM employee
WHERE LEFT( phone
視圖
CREATE VIEW emp_dept AS
SELECT emp_fname
FROM employee
JOIN department ON department
SELECT *
FROM emp_dept
(視圖能自動更新狀態)
DROP VIEW emp_dept
CREATE VIEW emp_dept(FirstName
SELECT emp_fname
FROM employee JOIN department ON department
(創建視圖不能使用ORDEY BY
SELECT LastName
FROM emp_dept
WHERE emp_dept
(將視圖與其他表進行進一步的連結)
視圖權限管理
GRANT CONNECT TO M_Kelly
IDENTIFIED BY SalesHead
CREATE VIEW SalesEmployee AS
SELECT emp_id
FROM
WHERE dept_id =
GRANT SELECT ON SalesEmployee TO M_Kelly
CONNECT USER M_Kelly IDENTIFIED BY SalesHead ;
SELECT * FROM
子查詢
SELECT *
FROM sales_order_items
WHERE prod_id IN
( SELECT id
FROM product
WHERE quantity <
ORDER BY ship_date DESC
SELECT *
FROM fin_data
WHERE de = ANY ( SELECT de
FROM fin_code
WHERE type =
(=ANY 相當於IN)
SELECT *
FROM fin_data
WHERE de <> ALL ( SELECT de
FROM fin_code
WHERE type =
(相當於NOT IN)
SELECT sales_order
( SELECT company_name
FROM customer
WHERE customer
FROM sales_order
WHERE order_date >
ORDER BY order_date
(如果其他表只要求產生一個字段
SELECT company_name
( SELECT MAX( id )
FROM sales_order
WHERE sales_order
FROM customer
WHERE state =
根據SQL Anywhere User
SELECT語句
SELECT *
FROM employee
SELECT *
FROM employee
ORDER BY emp_lname ASC
SELECT *
FROM employee
ORDER BY emp_lname DESC
SELECT emp_lname
FROM employee
SELECT *
FROM employee
WHERE emp_fname=
(一定使用單引號)
SELECT emp_fname
FROM employee
WHERE emp_fname =
ORDER BY birth_date
SELECT emp_lname
FROM employee
WHERE birth_date <
(=
SELECT emp_lname
FROM employee
WHERE emp_lname LIKE
(%
SELECT emp_lname
FROM employee
WHERE SOUNDEX( emp_lname ) = SOUNDEX(
(找出英文中發音相同的記錄
SELECT emp_lname
FROM employee
WHERE birth_date BETWEEN
SELECT emp_lname
FROM employee
WHERE emp_lname IN (
連接表
SELECT *
FROM sales_order
WHERE sales_order
SELECT E
FROM sales_order as S
WHERE S
ORDER BY E
連接兩表的快捷鍵
SELECT emp_lname
FROM sales_order
KEY JOIN employee
(主鍵與外部鍵對應的地方
SELECT company_name
CAST( SUM(sales_order_items
FROM customer
KEY JOIN sales_order
KEY JOIN sales_order_items
KEY JOIN product
GROUP BY company_name
SELECT emp_lname
FROM employee
NATURAL JOIN department
(找出兩表間有相同的字段名
集合
SELECT count( * )
FROM employee
SELECT count( * )
min( birth_date )
max( birth_date )
FROM employee
(MIN
SELECT sales_rep
FROM sales_order
GROUP BY sales_rep
(在使用GROUP BY時
SELECT sales_rep
FROM sales_order
KEY JOIN employee
GROUP BY sales_rep
HAVING count( * ) >
更新數據庫
INSERT
INTO department ( dept_id
VALUES (
INSERT
INTO department
VALUES (
UPDATE employee
SET dept_id =
WHERE emp_id =
DELETE
FROM employee
WHERE termination_date IS NOT NULL
DELETE
FROM employee
WHERE LEFT( phone
視圖
CREATE VIEW emp_dept AS
SELECT emp_fname
FROM employee
JOIN department ON department
SELECT *
FROM emp_dept
(視圖能自動更新狀態)
DROP VIEW emp_dept
CREATE VIEW emp_dept(FirstName
SELECT emp_fname
FROM employee JOIN department ON department
(創建視圖不能使用ORDEY BY
SELECT LastName
FROM emp_dept
WHERE emp_dept
(將視圖與其他表進行進一步的連結)
視圖權限管理
GRANT CONNECT TO M_Kelly
IDENTIFIED BY SalesHead
CREATE VIEW SalesEmployee AS
SELECT emp_id
FROM
WHERE dept_id =
GRANT SELECT ON SalesEmployee TO M_Kelly
CONNECT USER M_Kelly IDENTIFIED BY SalesHead ;
SELECT * FROM
子查詢
SELECT *
FROM sales_order_items
WHERE prod_id IN
( SELECT id
FROM product
WHERE quantity <
ORDER BY ship_date DESC
SELECT *
FROM fin_data
WHERE de = ANY ( SELECT de
FROM fin_code
WHERE type =
(=ANY 相當於IN)
SELECT *
FROM fin_data
WHERE de <> ALL ( SELECT de
FROM fin_code
WHERE type =
(相當於NOT IN)
SELECT sales_order
( SELECT company_name
FROM customer
WHERE customer
FROM sales_order
WHERE order_date >
ORDER BY order_date
(如果其他表只要求產生一個字段
SELECT company_name
( SELECT MAX( id )
FROM sales_order
WHERE sales_order
FROM customer
WHERE state =
SELECT company_name
FROM customer
KEY LEFT OUTER JOIN sales_order
WHERE state =
GROUP BY company_name
系統表
SYSCATALOG
SYSCOLUMNS
FROM customer
KEY LEFT OUTER JOIN sales_order
WHERE state =
GROUP BY company_name
系統表
SYSCATALOG
SYSCOLUMNS
From:http://tw.wingwit.com/Article/program/Oracle/201311/16984.html