软件测试mysql常用语句_测试中常用到的SQL语句(Oracle)
在測試過程中,可能會進入到數(shù)據(jù)庫中檢查數(shù)據(jù)。
下面列舉一些經(jīng)常用到的SQL語句。
(1)刪除記錄(delete與truncate)
語法:delete from? 表名 where 條件
truncate table 表名
區(qū)別:delete可選擇性的刪除數(shù)據(jù),操作可回滾。truncate刪除表中所有數(shù)據(jù),操作不可回滾。
(2)更新記錄(update)
語法:update 表名 set 字段1=值1,字段2=值2,字段3=值3,... where 條件
(3)查詢記錄(select)
語法:select * from 表名 where 條件
(4)表示條件的符號
<>表達式1
in(表達式1,表達式2,表達式3,...)
not in(表達式1,表達式2,表達式3,...)
between 表達式1 and 表達式2
not between 表達式1 and 表達式2
like?表達式1
not like 表達式1
is null
is not null
(5)并集(union)
(select 字段 from 表1) union (select 字段 from 表2)
(6)交集(intersect)
(select 字段 from 表1) intersect (select 字段 from 表2)
(7)差集(minus)
(select 字段 from 表1) minus(select 字段 from 表2)
(8)計數(shù)函數(shù)(count)
select count(*) from 表名
select count(字段) from 表名
(9)求最小值函數(shù)(min)
select min(字段名) from 表名
(10)求最大值函數(shù)(max)
select max(字段名) from 表名
(11)求和函數(shù)(sum)
select sum(字段名) from 表名
(12)插入數(shù)據(jù)記錄(insert into)
直接插入值
insert into 表名(字段1,字段2,字段3,...) values(值1,值2,值3,...)
將其他表中的數(shù)據(jù)插入到當前表中
insert into 表名(字段1,字段2,字段3,...) (select 字段1,字段2,字段3,...?from?表2 where 條件)
(13)數(shù)值類型轉(zhuǎn)換
to_char(sysdate,'yyyy-mm-dd hh24:mi:ss')
to_date('2004-05-07 13:23:44','yyyy-mm-dd hh24:mi:ss')
to_date('2002-02-28','yyyy-mm-dd')
(14)dual表與sys_guid()函數(shù)
oracle中的dual表是oracle庫內(nèi)的特殊表,任何用戶均可讀取,常用于沒有目標表的select語句中。
表結(jié)構(gòu)中只有1列 dummy,varchar2(1)類型,只有1行數(shù)據(jù)。如:
select sys_guid()from dual
sys_guid()函數(shù)用于生成UUID。
總結(jié)
以上是生活随笔為你收集整理的软件测试mysql常用语句_测试中常用到的SQL语句(Oracle)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java 钩子_java中钩子方法的概念
- 下一篇: linux cmake编译源码,linu