如何打击网站,网站怎么做3d商品浏览,html5手机网站开发经验,网页设计与网站建设连接数据库整理一下第一天软件测试培训的知识点
1、scott用户
-- 以system管理员登录锁定scott用户
alter user scott account lock;-- 以system管理员登录解锁scott用户
alter user scott account unlock;-- 以system管理员用户设置scott用户密码
alter user scott identfied by tiger…整理一下第一天软件测试培训的知识点
1、scott用户
-- 以system管理员登录锁定scott用户
alter user scott account lock;-- 以system管理员登录解锁scott用户
alter user scott account unlock;-- 以system管理员用户设置scott用户密码
alter user scott identfied by tiger;
前提条件
使用system管理员账号登录了这时解锁了scott普通用户
在scott用户下有emp员工信息表
-- 前提在scott普通账号下有一个emp表
-- emp 员工信息表-- empno 员工编号 number数字类型--ename 员工姓名 varchar2字符串类型--job 工作岗位 varchar2字符串类型--mgr 上级领导 number数字类型--hiredate 入职日期 date时间类型--sal 工资number类型--comm 奖金number类型--deptno 部门编号 number
后面的内容都基于scott的emp表进行操作
2、DQL操作 -- 查询 DQL操作对已有的表进行数据的查询和筛选 select -- 选择、查询 select * from 表名; scott用户可以省略 *通配符表示所有列和列名同时存在时应写为表名.* 2.1、select 查询语句
-- 1、查询全部数据
-- 此时在管理员账号查询scott账号下的emp表
select * from scott.emp;
-- 如果当前是scott可以省略scott
-- select * from emp;-- 2、查询指定列的数据
-- select 列1,列2 from 表;
select empno,ename from scott.emp;-- 3、查询满足条件的值
-- 查询工资3000的人
select empno,ename from scott.emp where sal 3000;select emp.*,sal from scott.emp where sal 3000;2.2、对数字列进行计算
-- 4、对数字列进行运算
/*-*/% -- 取余
*/
select emp.*,sal200,sal-50,sal*1.3,sal/1.2 from scott.emp;
-- emp.*是查询到了emp表的所有列然后后面就可以拼接其他列一共查询到12列
-- 对列进行运算会产生一个新的列
-- 每一列都是独立的都是独立的重新从原有基础上进行运算而不是从前一列再运算2.3、向上ceil/下floor取整
/*取整1、ceil() 向上取整2、floor() 向下取整
*/
-- 当小数不为零ceil向上往大的数走取整
select emp.*,ceil(sal200.5) from scott.emp;-- 当小数不为0floor往下往小的数走取整
select emp.*,floor(sal200.2) from scott.emp;-- 如果小数部分为0ceil和floor直接取整数部分-- celi和floor并不是四舍五入如果是-4.1同时使用celi和floor
-- ceil(-4.1)取到的值是-4向上取整往大了取
-- floor(-4.1)取到的值则是-5向下取整往小的取
2.4、时间date
/*时间date*/
-- sysdate 系统时间返回值是 日期
-- current_date 当前时间返回值是 日期
select sysdate,current_date from dual;2.5、截取日期
-- 2、截取sal表中的日期hiredate
/*a的值为时间列n的值可以有以下1、mm - 返回当月第一天2、yy - 返回当年第一天3、dd - 返回当前年月日4、yyyy - 返回当年第一天5、d - 星期天返回当前星期的第一天6、hh - 当前时间7、mi - 没有秒的精准度
*/
select trunc(hiredate,dd) from scott.emp;
select trunc(hiredate,yy) from scott.emp;
2.6、四舍五入
/*四舍五入、截取1、round(a,n) 四舍五入n表示小数位n省略则四舍五入到整数部分2、trunc() 用于截取时间和数字的函数3、trunc(a,n) 用于截取时间和数字的函数n表示小数的位数n省略表示截取到整数部分
*/
select * from scott.emp;
-- 1、运算 sal工资乘1.2然后四舍五入
select round(sal * 1.2,2) from scott.emp;
2.7 列别名
/*取别名1、给列取别名列可以是已有的列也可以是运算生成的列 在低版本语法中需要加上asselect age 别名,name 别名注意1、as可以省略2、列名不能重复3、别名建议不重复别名可以用双引号进行包裹4、别名不要使用关键字
*/
select * from scott.emp;
select ename 名字 from scott.emp; -- 给emp的ename取别名
2.8 表别名
/*对表取别名表取别名后出现表名时候必须要使用别名否则报错别名不能重复表别名可以使用双引号
*/
select * from scott.emp a; -- 这是给表取了个别名a
select * from scott.emp a1; -- 这种别名可以用双引号包括-- 给表的列取别名
select emp.*,sal/1.2 sal1,trunc(sal/1.2) sal2 from scott.emp;
-- 此时如果给表取一个别名这个时候在列的部分使用 emp就不对了
select e.*,sal/1.2 sal1,trunc(sal/1.2) sal2 from scott.emp e;
-- 这个时候emp就应该换成别名来代替了,如果不用别名提示标识符错误
-- 例如这样
select e.ename from scott.emp e;
2.9 where查询
/*带where条件的查询-- 可带有 (! )不等于-- 比较运算符两边的数据类型需要一致
*/
-- 精准查询
select * from scott.emp where deptno 10; -- deptno 部门号
-- 数字类型是可以加上 单引号的
select * from scott.emp where deptno 10;-- 范围筛选
select * from scott.emp where sal 1000;
2.10 模糊查询
-- 模糊查询
-- -1、以 A开头的 A%
-- -2、以A结尾的%A
-- -3、包含A%A%
-- -4、
-- 语法查询 where 条件列 like 模糊条件
-- 找出以A开头的
select * from scott.emp where ename like A%;-- 找出以A结尾的
select * from scott.emp where ename like %A;-- 找出包含A的
select * from scott.emp where ename like %A%;2.11 用函数来模糊查询
-- 在数据量大的情况下link的弊端会体现出来
/*这个时候就可以使用到函数substr()substr(str,begin,[num])在str中从begin位置开始连续截取num数量的字符可以正向和反向截取正向从1开始反向从-1开始substr(str,begin)在str中从begin位置开始截取str字符串的末尾如果没有就返回空值字符串的最后一位正向数是字符串的长度 反向数是-11、以A开头substr(字符串,开始的位置截取的长度) Asubstr(字符串,1,1) A2、以A结尾substr(字符串,-1,1) Asubstr(字符串,-1) A 从末尾结尾时后面的1可以省略
*/
-- 语句查询以A开头
select * from scott.emp where substr(ename,1,1) A;-- 语句查询以A结尾
select * from scott.emp where substr(ename,-1,1) A;
select * from scott.emp where substr(ename,-1) A;/*也可以用字符串的长度函数来操作substr(字符串,-length(字符串),1) Asubstr(字符串,length(字符串),1) Asubstr(字符串,length(字符串)) A
*/
-- 1、以A开头
select * from scott.emp where substr(ename,-length(ename),1) A;-- 2、以A结尾
select * from scott.emp where substr(ename,length(ename),1) A;
select * from scott.emp where substr(ename,-length(ename)) A;-- 如果在这里给列取了别名那么在 查询条件中使用列别名就会出错因为
-- 别名是在查询结束以后才会产生在查询期间是无效的--3、查询员工姓名第三位是A的
select * from scott.emp where ename like __A%;
select ename,substr(ename,3,1) from scott.emp where substr(ename,3,1) A;-- 4、查询第三位是A第五位是E的记录
select * from scott.emp where ename like __A_E%;select ename,substr(ename,3,1),substr(ename,5,1) from scott.emp
where
substr(ename,3,1) A
and
substr(ename,5,1) E;2.12 逻辑运算符
/*逻辑运算符and两个条件同时满足并且or两个条件满足其一和not不是-- 执行顺序先not、再and后or
*/
逻辑运算符练习
-- 1、查询10号部门和20号部门的员工信息
select * from scott.emp where deptno 10 or deptno 20;-- 2、查询10号部门中工资超过2000的员工信息两个条件同时满足条件并且
select * from scott.emp where deptno 10 and sal 2000;-- 3、查询10号部门中工资超过2000的员工信息和20号部门且工资小于1000的两个条件同时满足条件并且
select * from scott.emp where deptno 10 and sal 2000;
select * from scott.emp where deptno 10 and sal 2000
or deptno 20 and sal 1000;-- 4、查询10号和20号两个部门中工资都高于2000的员工信息并且
select * from scott.emp where (deptno 10 or deptno 20) and sal 2000;-- 5、查询不是20号部门的员工
select * from scott.emp where deptno 20;
select * from scott.emp where deptno ! 20;-- 6、找出工资大于800的员工 CLERK 和工资大于900的销售员 SALESMAN
select * from scott.emp where (job CLERK and sal 800) or (job SALESMAN and sal 800);