oracle入門操作二

2021-10-10 10:24:33 字數 3905 閱讀 3334

oracle入門操作二

**內容的修改必須要使用commit或rollback去提交或者回滾**的資料。(圖中綠色的圖示代表提交,紅色的圖示代表回滾。提交操作後,原表資料發生變化,回滾操作後,原表資料不發生變化)

往已有的**中新增資料

insert into 插入資料到哪個位置

第一種句式:往**的每一列都新增乙個資料

insert into 表名 values(資料1,資料2…);

insert

into class_info values

(1001

,'一年一班'

,'***'

);

第二種句式:往**的部分列新增資料(可以針對**中的部分資料插入,即某些列的資料為普通非必填的列,可以不插入資料)

insert into 表名(列名1,列名2) values(資料1,資料2);

insert

into class_info(class_id,cname)

values

(1004

,'一年四班'

);

更新**中的資料update 更新 set 設定

update **名 set 列=新值 where 列=值;

例:設定學生編號為2的學生生日為2012-09-19

update student set birth=

date

'2012-09-19'

where stuid=

2;

刪除**中已存在的資料delete from 從**刪除資料

刪除整個**的所有資料:

delete from 表名;

delete

from student;

刪除符合條件的資料

delete

from student where stuid=

2;

使用create和insert進行**的複製(1)複製的**與原**結構資料一樣,只是不會有原表的約束條件

例:複製學生表student為student2

create

table student2 as

select

*from student;

(2)複製**但是不複製內容

例:複製學生表student的結構,新錶名為student3(因為where中的條件不符合,所以只複製表結構)

create

table student3 as

select

*from student where1=

2;

(3)使用insert對已存在的表進行內容的複製

例:將student表中學號為1的學生資訊插入到student3表中。(前提兩張表的結構一致)

insert

into student3 select

*from student where stuid=

1;

刪除表drop table 表名;

例:刪除表student3

drop

table student3;

(1)從哪個表中選擇所有的列進行展示

select * from 表名;

例:查詢emp表中所有的資料

select

*from emp;

(2)選擇部分列進行查詢

select 列名,列名 from 表名;

例:查詢emp表中empno、ename、sal列中的資料

select empno,ename,sal from emp;
(3)按條件查詢資料

select 列名… from emp where 條件;

例:查詢deptno(部門編號)為20部門的所有人員資訊

select

*from emp where deptno=

20;

(4)資料的範圍查詢:(大於) <=(小於等於) >=(大於等於) !=(不等於)

例:查詢工資小於1500的員工資訊

select

*from emp where sal<

1500

;

例:查詢部門編號不為20的員工資訊

select

*from emp where deptno !=

20;

(5)資料的邏輯查詢:not、and、or

例:部門不等於20的員工資訊。

select

*from emp where

not deptno=

20;

例:部門等於20,工資小於1500的員工資訊。

select

*from emp where deptno=

20and sal<

1500

;

(6)資料的模糊查詢 like

% 萬用字元,表示在這個位置有0-n個任意的字元內容

_ 萬用字元,表示在這個位置有1個任意的字元內容

\ 轉義符,當%時,代表%是個普通的字元。『\』代表是乙個『\』字元

escape是用來標註『\』轉義符的特殊單詞。

例如:查詢名字中a開頭的員工資訊。(%萬用字元的應用)

select

*from emp like

'a%'

;

例:查詢名字中第二個字母為m的員工資訊。(_萬用字元的應用)

select

*from emp like

'_k%'

;

例:檢視名字中包含%字元的員工資訊。(\和escape的應用)

select

*from emp where ename like

'%\%%%'

escape'\';

(7)搜尋null(空值)的內容

例:搜尋mgr為空的資訊

select

*from emp where mgr is

null

;

(8)範圍搜尋(in和between…and…)

in 在什麼裡面,比如搜尋食物在(蘋果、梨、炸雞)裡,只要符合任意一種條件都能搜尋出來。

between…and… 在什麼範圍之間,通常用來計數、日期,比如學號在20–50之間,那麼between…and…是有前後關係的。

例:搜尋員工編號為(7369,7499,7788)

select

*from emp where empno in

(7369

,7499

,7788

);

例:查詢員工工資在1000和3000之間的員工資訊

select

*from emp where sal between

1000

and3000

;

Jquery屬性操作(入門二)

jquery屬性相關的操作 1 屬性 屬性 如果你的選擇器選出了多個物件,那麼預設只會返回出第乙個屬性 attr 屬性名 屬性值 乙個引數是獲取屬性的值,兩個引數是設定屬性值 點選載入示例 removeattr 屬性名 刪除屬性的值 prop 屬性名 屬性值 屬性的返回值的是布林型別 單選,反選,取...

Oracle資料庫入門 二

oracle sql plus常用命令 一 sys使用者和system使用者 oracle安裝會自動的生成sys使用者和system使用者。1 sys使用者時超級使用者,具有最高許可權,具有sysdba角色,有create database的許可權,該使用者預設的密碼是change on insta...

ORACLE資料庫操作基礎入門

oracle資料庫操作入門 1 資料庫工作環境基礎設定 在linux下用oracle使用者登陸作業系統,然後用sqlplus 以資料庫的超戶 登陸 資料庫 oracle home bin sqlplus as sysdba 建立表空間 sql create tablespace its datafi...