日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

集合操作

發(fā)布時間:2023/12/15 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 集合操作 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

集合操作
union 并集 去除重復值
union all 也是并集 不去除重復值
例:
select employee_id, job_id from employees
union all
select employee_id, job_id from job_history;

select employee_id, job_id from employees
union
select employee_id, job_id from job_history;

intersect 交集
select employee_id, job_id from employees
intersect
select employee_id, job_id from job_history;

minus 差集
select employee_id from employees
minus
select employee_id from job_history;


select employee_id, job_id, salary from employees
union all
select employee_id, job_id, null from job_history;
// 如果不能提供這個值 就用空值代替


集合排序:
select employee_id, job_id, salary from employees
union all
select employee_id, job_id, null from job_history
order by salary;
//order by只寫一個 寫在最后一個后面
select employee_id, job_id, null from job_history
union all
select employee_id, job_id, salary from employees
order by 3;
如果沒有名字就用第幾列或者用別名

DML
insert:
SQL> create table t1(x int, y char(1), z date);
SQL> insert into t1(x, y, z) values (1, 'a', sysdate);
SQL> insert into t1(x, z, y) values (2, sysdate+1, 'b');
SQL> insert into t1(x, y, z) values (1, null, sysdate);
SQL> insert into t1(x, z) values (2, sysdate+1);
SQL> insert into t1 values (1, null, sysdate)
//insert 定義列 列的聲明 values 后面加列的值


create table my_emp as select * from employees; //復制表 只復制了數據和基本結構 沒有附加結構
SQL> create table my_emp as select * from employees where 1=0;// 一張空的表 復制表結構 后面where 1=0 不可能實現所以查詢的是空的

?


update 更新
SQL> update my_emp set salary=salary*1.1;
SQL> update my_emp set salary=salary*1.1 where department_id=50;
SQL> update my_emp set salary=salary*1.1, commission_pct=0.5 where employee_id=197;
//定位行 更新列


在new_dept表中刪除沒有員工的部門
SQL> create table my_dept as select * from departments;
delete from my_dept outer
where not exists
(select 1 from my_emp
where department_id=outer.department_id);

?

delete和truncate: delete truncate
語句類型 dml ddl
undo數據 產生大量undo數據 不產生undo數據
空間管理 不釋放 釋放
語法 where 刪除全部數據

轉載于:https://www.cnblogs.com/luo102154/p/7270496.html

總結

以上是生活随笔為你收集整理的集合操作的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。