亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Oracle學習筆記之第八節sql語句(開發課學生指南051)

發布時間:2020-07-18 15:15:21 來源:網絡 閱讀:466 作者:guosmile 欄目:關系型數據庫

 開發課 做練習 學生指南051 les01 ppt

 oracle經常兩表連接,叫第三范式,如帶有ID性質的東西

 以下是sql語句的命令

 select * from departments; 部門表

select * from employees; 員工表

select employee_id,rowid,rownum from employees

where employee_id>=200;  64進制內部運算 rownum本質查詢第幾行


select employee_id,rowid,rownum from employees

where rownum<=5; 查看前5行


select * from employees e where e.department_id=80; 這部門里的人都有提成 

select last_name,12*salary*(1+commission_pct) from employees; 查看年收入

select last_name,12*salary*(1+nvl(commission_pct,0)) from employees; 查看年收入,處理空行的顯示

select * from employees where manager_id is null; 關于空的處理

select last_name,12*salary*(1+nvl(commission_pct,0)) as anaualsal  from employees;進行列別名處理

select last_name,12*salary*(1+nvl(commission_pct,0)) "Anaualsal"  from employees;如果要區分大小寫要加雙引號

select last_name ||'xxxx'|| job_id from employees; 連起來顯示

select department_name || q'[ department's manager id:]' || manager_id as "Department and Manager" from departments;    q'#xxx# 也可以, 后面就是你想要的東西

select DISTINCT department_id from employees; 有除重必須排序(空有顯示,178號員工沒部門) 



create table t05101_distinct (a varchar2(10),b varchar2(10));

insert into t05101_distinct values ('A','B');

select * from t05101_distinct;

select distinct a,b from t05101_distinct;

insert into t05101_distinct values ('A','B1');  除重是除掉整行

select distinct a,b from t05101_distinct;

select * from user_tab_cols tc where tc.TABLE_NAME='LOCATIONS'; 查看用戶范圍內的所有表的所有列

方法2:sqlplus命令

sqlplus /nolog

conn hr/oracle_4U

describe  locations  查看表結構




小提示:選中SQL 按F5看執行計劃

 

les02 ppt

oracle變量有6種+1形參,兩種宿主


select * from employees where rownum=1;

alter session set nls_date_format='YYYY-MM-DD';修改當前會話默認格式

select last_name from employees where hire_date = to_date('17-JUN-07','DD-MON-RR');


select * from employees e where e.employee_id in (select manager_id from employees);查看多少人是老板管過人

select * from employees e where e.employee_id not in (select manager_id from employees);這個例子是錯誤的。不能not in 因為里頭有空值取反還是空

select * from employees e where e.employee_id not in (select manager_id from employees where manager_id is not null);這樣才有顯示89個人



create table t05102_a (a varchar2(10));

insert into t05102_a values ('A');

insert into t05102_a values ('A1');

insert into t05102_a values ('%');

insert into t05102_a values ('_');

insert into t05102_a values ('_1');

select * from t05102_a;

select * from t05102_a where a like 'A%'; A打頭的東西

select * from t05102_a where a like 'A_';查看A打頭的東西


select * from t05102_a where a like '\%%' escape '\'; 查看%號

select * from t05102_a where a like '\_%' escape '\';查看下劃線打頭的

insert into t05102_a values('''');插入單引號

insert into t05102_a values(chr(39)||1); man ascii查看得來的


create table t05102_b (a number,b number);

insert into t05102_b values(1,999);

insert into t05102_b values(1,0);

insert into t05102_b values(2,999);

insert into t05102_b values(2,0);

select * from t05102_b order by a,b;先按a排列在按照b排列

select * from t05102_b order by a desc ,b desc;   

select a "X", b "Y" from t05102_b order by "X" desc,"Y" desc;別名,在order by世界里無所謂是“X”還是a都可以,但是正常語句的sql語句的別名不行


替換變量

select employee_id,salary from employees where employee_id=100;

select employee_id,salary from employees where employee_id=&S_1; 可以進出彈窗,自己選擇ID號

select last_name,salary from employees where last_name like '&S_1%';可以進出彈窗

sqlplus /nolog

select  salary from employees where employee_id=&&s_2;問兩次后永遠都是這個

define 默認在這了

undefine s_2 取消

select  &&s2,salary from employees where employee_id=&s_2;

set verify off 配置這個后就不會有舊的新的,環境變量


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

安阳市| 囊谦县| 石楼县| 东山县| 山丹县| 固始县| 怀柔区| 河源市| 北安市| 上思县| 高阳县| 罗山县| 泸溪县| 五峰| 延寿县| 江北区| 云林县| 东港市| 浮梁县| 漳平市| 翁源县| 齐河县| 宾阳县| 岳阳市| 孝昌县| 龙江县| 尖扎县| 遂宁市| 婺源县| 泊头市| 安宁市| 金乡县| 桐柏县| 乡宁县| 东明县| 阜康市| 浠水县| 民丰县| 东乡县| 浏阳市| 剑川县|