使用工具sqldeveloper
請先參考 sqldeveloper下載及安裝及連線
測試資料來源請先參考 Oracle DB 目錄
先看
關鍵詞(keyword): UPDATE
UPDATE
修改表格裡的資料
基本用法:
UPDATE TABLE SET 欄位 = '更新資料' WHERE 條件;
簡單測試語法:
UPDATE BOOK SET BOOK_NAME='Oracle用法' WHERE BOOK_ID = 1;
測試:
其它文章
本站Java鬥陣仔甘仔店為學徒程式開發教學學習,這裡有Java程式開發相關技術等學習交流。 主要提高開發程式效率同時分享一些開發程式經驗、深入探討開發程式體驗等技術和教學。 相關技術等學習交流語言(Languages)及框架工具(Software)/環境(Environment)/資料庫(Database)
UPDATE BOOK SET BOOK_NAME='Oracle用法' WHERE BOOK_ID = 1;
DELETE FROM BOOK WHERE BOOK_ID = 1;
DROP TABLE BOOK ;
INSERT INTO BOOK (BOOK_ID, BOOK_NAME) VALUES (1, 'oracle基本用法');
CREATE TABLE BOOK (BOOK_ID number , BOOK_NAME varchar2(30));
(-- 100 ~ 115 SELECT employee_id,last_name,salary FROM employees WHERE employee_id between 100 and 105 UNION SELECT employee_id,last_name,salary FROM employees WHERE employee_id between 105 and 115 ) intersect (-- 110 ~ 114 SELECT employee_id,last_name,salary FROM employees WHERE employee_id between 110 and 118 minus SELECT employee_id,last_name,salary FROM employees WHERE employee_id between 115 and 120 );測試:
SELECT employee_id,last_name,salary FROM employees WHERE employee_id between 110 and 118 union all SELECT employee_id,last_name,salary FROM employees WHERE employee_id between 115 and 120 order by employee_id; ;測試:
SELECT employee_id,last_name,salary FROM employees WHERE employee_id between 110 and 118 intersect SELECT employee_id,last_name,salary FROM employees WHERE employee_id between 115 and 120 ;測試:
SELECT employee_id,last_name,salary FROM employees WHERE employee_id between 110 and 118 minus SELECT employee_id,last_name,salary FROM employees WHERE employee_id between 115 and 120 ;測試:
SELECT employee_id,last_name,salary FROM employees WHERE employee_id between 110 and 118 UNION SELECT employee_id,last_name,salary FROM employees WHERE employee_id between 115 and 120 ;測試:
SELECT employee_id,last_name,salary FROM employees WHERE employee_id between 110 and 118 UNION ALL SELECT employee_id,last_name,salary FROM employees WHERE employee_id between 115 and 120 ;測試:
SELECT DEPARTMENT_ID, DEPARTMENT_NAME FROM departments d WHERE DEPARTMENT_ID NOT IN(select DEPARTMENT_ID from employees e);
SELECT DEPARTMENT_ID, DEPARTMENT_NAME FROM departments d WHERE NOT exists(select * from employees e where d.department_id=e.department_id) ;測試:
SELECT DEPARTMENT_ID, DEPARTMENT_NAME FROM departments d WHERE exists(select * from employees e where d.department_id=e.department_id) ;
SELECT department_id, max(salary) FROM employees group by department_id having department_id > ( select department_id from departments where DEPARTMENT_ID=50 )
SELECT employee_id, last_name, salary, d.DEPARTMENT_NAME FROM employees JOIN ( select * from departments where DEPARTMENT_ID=50 ) d ON employees.DEPARTMENT_ID = D.DEPARTMENT_ID;
SELECT employee_id, last_name, salary FROM employees WHERE salary > ANY( select MAX(salary) from employees group by department_id having MAX(salary) >10000 ) ORDER BY employee_id;
SELECT employee_id, last_name, salary FROM employees WHERE salary >= all( select MAX(salary) from employees ) ORDER BY employee_id;
SELECT EMPLOYEE_ID, FIRST_NAME, JOB_ID, SALARY, DEPARTMENT_ID FROM EMPLOYEES WHERE salary = SOME( 24000,12000,10000 ) ORDER BY employee_id;
SELECT EMPLOYEE_ID, FIRST_NAME, JOB_ID, SALARY, DEPARTMENT_ID FROM EMPLOYEES WHERE salary > SOME( 24000,12000,10000 ) ORDER BY employee_id;
SELECT d.* FROM departments d where d.DEPARTMENT_ID > SOME( select DEPARTMENT_ID from departments where DEPARTMENT_ID=50 ) ;測試:
SELECT EMPLOYEE_ID, FIRST_NAME, JOB_ID, SALARY, DEPARTMENT_ID FROM EMPLOYEES WHERE salary = ANY( 24000,12000,10000 ) ORDER BY employee_id;
SELECT EMPLOYEE_ID, FIRST_NAME, JOB_ID, SALARY, DEPARTMENT_ID FROM EMPLOYEES WHERE salary > ANY( 24000,12000,10000 ) ORDER BY employee_id;
SELECT d.* FROM departments d where d.DEPARTMENT_ID > ANY( select DEPARTMENT_ID from departments where DEPARTMENT_ID=50 ) ;測試:
SELECT EMPLOYEE_ID, FIRST_NAME, JOB_ID, SALARY, DEPARTMENT_ID FROM EMPLOYEES WHERE salary = ALL( 12000,10000 ) ORDER BY employee_id;
SELECT EMPLOYEE_ID, FIRST_NAME, JOB_ID, SALARY, DEPARTMENT_ID FROM EMPLOYEES WHERE salary > ALL( 12000,10000 ) ORDER BY employee_id;
SELECT d.* FROM departments d where d.DEPARTMENT_ID in( select DEPARTMENT_ID from departments ) ;
SELECT d.* FROM departments d where d.DEPARTMENT_ID =( select DEPARTMENT_ID from departments where DEPARTMENT_ID=10 ) ;
SELECT t.* FROM ( select d.DEPARTMENT_NAME, ( select count(*) from employees e where d.department_id = e.department_id ) total from departments d ) t WHERE t.total>0;
SELECT t.* FROM ( select d.DEPARTMENT_NAME from departments d ) t;
SELECT d.DEPARTMENT_NAME, ( select count(*) from employees e where d.department_id = e.department_id ) 部門總人數 FROM departments d;
SELECT e.first_name, e.salary, d.department_name, l.city FROM employees e JOIN departments d ON ( e.department_id = d.department_id ) JOIN locations l ON l.location_id = d.location_id ;
SELECT employee_id, department_name, department_id FROM employees INNER JOIN departments ON ( employees.department_id = departments.department_id);
SELECT employee_id, department_name, employees.department_id FROM employees INNER JOIN departments ON ( employees.department_id = departments.department_id);
SELECT EMPLOYEE_ID, FIRST_NAME, DEPARTMENT_NAME FROM employees CROSS JOIN departments;
SELECT EMPLOYEE_ID, FIRST_NAME, DEPARTMENT_NAME FROM employees , departments;
select employee_id, department_name from employees join departments using(department_id);
select employee_id, department_name from employees natural join departments;
SELECT e1.EMPLOYEE_ID, e1.FIRST_NAME, e1.MANAGER_ID FROM employees e1 JOIN employees e2 ON( e1.MANAGER_ID = e2.EMPLOYEE_ID);
SELECT e1.EMPLOYEE_ID, e1.FIRST_NAME, e1.MANAGER_ID FROM employees e1 JOIN employees e2 ON( e1.MANAGER_ID = e2.EMPLOYEE_ID);
SELECT employees.EMPLOYEE_ID, employees.FIRST_NAME, employees.DEPARTMENT_ID, departments.DEPARTMENT_ID, department_name FROM employees FULL OUTER JOIN departments ON( employees.department_id = departments.department_id);
SELECT employees.EMPLOYEE_ID, employees.FIRST_NAME, employees.DEPARTMENT_ID, departments.DEPARTMENT_ID, department_name FROM employees RIGHT OUTER JOIN departments ON( employees.department_id = departments.department_id);
SELECT employees.EMPLOYEE_ID, employees.FIRST_NAME, employees.DEPARTMENT_ID, departments.DEPARTMENT_ID, department_name FROM employees LEFT OUTER JOIN departments ON( employees.department_id = departments.department_id);
SELECT e.EMPLOYEE_ID, e.FIRST_NAME, j.JOB_ID, e.SALARY FROM employees e JOIN JOBS j ON e.SALARY BETWEEN j.MIN_SALARY AND j.MAX_SALARY ORDER BY e.EMPLOYEE_ID;
SELECT employees.EMPLOYEE_ID, employees.FIRST_NAME, employees.DEPARTMENT_ID, departments.DEPARTMENT_ID, department_name FROM employees JOIN departments ON( employees.department_id = departments.department_id);
撰寫一個JAVA程式 public class HelloWorld{ public static void main(String[ ] args){ System.out.println("我第一支Java程式!!"); } } ...