oracle學習筆記四

2021-09-01 10:31:51 字數 2579 閱讀 3154

select table1.column, table2.column

from table1

[cross join table2] |

[natural join table2] |

[join table2 using (column_name)] |

[join table2

on(table1.column_name = table2.column_name)] |

[left|right|full outer join table2

on (table1.column_name = table2.column_name)];

交叉連線 cross join

oracle 8i中

select * from employees,departments;

oracle 9i中

select * from employees cross join departments;

自然連線 natural join

oracle 8i

select * from emp e,dept d where e.deptno=d.deptno;

oracle 9i

select * from emp natural join dept;

select * from emp join dept using (deptno);

on子名

sql-1999

select * from emp;

select * from dept;

select e.ename,e.empno,d.dname,d.deptno

from emp e join dept d on(e.deptno=d.deptno);

三個表的內連線

select * from employees;

select * from location;

select * from departments;

oracle8i等值接連

select e.employee_id,e.first_name||e.last_name,d.department_id,d.department_name,l.loc,l.city

from employees e,departments d,location l where e.department_id=d.department_id and d.location_id=l.location_id;

sql-1999

select e.employee_id,e.first_name||e.last_name,d.department_id,d.department_name,l.loc,l.city

from employees e join departments d on(e.department_id=d.department_id) join location l on(d.location_id=l.location_id);

左外連線 left outer join 對連線條件中左邊的表中的記錄不加限制

oracle8i右外接連

select e.employee_id,e.first_name||e.last_name,d.department_id,d.department_name

from employees e, departments d where e.department_id=d.department_id(+);

sql-1999

select e.employee_id,e.first_name||e.last_name,d.department_id,d.department_name

from employees e left outer join departments d on(e.department_id=d.department_id);

右外連線 right outer join 對連線條件中右邊的表中的記錄不加限制

oracle8i左外接連

select e.employee_id,e.first_name||e.last_name,d.department_id,d.department_name

from employees e, departments d where e.department_id(+)=d.department_id;

sql-1999

select e.employee_id,e.first_name||e.last_name,d.department_id,d.department_name

from employees e right outer join departments d on(e.department_id=d.department_id);

全外連線 full outer join 全外連線是對兩個表中的記錄都不加限制。

select e.employee_id,e.first_name||e.last_name,d.department_id,d.department_name

from employees e full outer join departments d on(e.department_id=d.department_id);

oracle學習筆記四

資料庫管理 sys使用者 對應乙個方案 基表和動態檢視 dba 資料庫管理員 sysdba 系統管理員 sysoper 系統操作員 只能以sysdba或sysoper登入 system 對應乙個方案 次級使用者資料 dba sysdba show parameter 資料庫表的邏輯備份與恢復 匯出 ...

oracle 學習筆記四

selecttable1.column,table2.column fromtable1 cross join table2 natural join table2 join table2 using column name join table2 on table1.column name tab...

學習oracle筆記 表與字段(四)

前言 約束分為兩種,一種是列約束,一種是表約束。列約束是指定義在乙個列上的約束,表約束指定義在兩個或多個列上的約束。10.primary key 約束 alter table mytable add constraints name primary key field field.11.unique...