–修改用户scott账户解锁,–修改用户scott账户解锁

–scott用户无法应用,使用system登录
–修改用户scott账户解锁
ALTER USER SCOTT ACCOUNT UNLOCK;
–重新设置密码 (identified 被识其他)
alter user scott identified by tiger;

–scott用户不可能应用,使用system登录
–修改用户scott账户解锁
ALTER USER SCOTT ACCOUNT UNLOCK;
–重新设置密码 (identified 被识别的)
alter user scott identified by tiger;

–接纳 全部字段 scott用户部门表
SELECT * FROM scott.dept;
–员工表
SELECT * FROM scott.emp;

–采用 全体字段 scott用户单位表
SELECT * FROM scott.dept;
–员工表
SELECT * FROM scott.emp;

–SELECT{*, column [alias],…}FROM table;
SELECT empno,ename,sal FROM scott.emp;

–SELECT{*, column [alias],…}FROM table;
SELECT empno,ename,sal FROM scott.emp;

–SELECT语句中的算术表明式
SELECT empno,ename,sal,sal * 12 FROM scott.emp;

–SELECT语句中的算术表明式
SELECT empno,ename,sal,sal * 12 FROM scott.emp;

–运算符的优先级
SELECT empno,ename,sal,sal * 12 + 100 FROM scott.emp;
SELECT empno,ename,sal,sal * (12 + 100) FROM scott.emp;

–运算符的先期级
SELECT empno,ename,sal,sal * 12 + 100 FROM scott.emp;
SELECT empno,ename,sal,sal * (12 + 100) FROM scott.emp;

–字符串的连日操作符 \\(相当于java的++)
–把八个字段的数目接纳_连接起来
SELECT empno ||’_’|| ename FROM scott.emp;

–字符串的连日操作符 \\(相当于java的++)
–把五个字段的数量利用_连接起来
SELECT empno ||’_’|| ename FROM scott.emp;

/**
重点:NULL 空值
空值是指不可用,未分配的值
空值不等于零或空格
自由档次都足以支撑空值
席卷空值的任何算术表明式都等于空
*/
–查询scott用户的emp表的有所列
SELECT * FROM scott.emp;
–查询scott用户的emp表的兼具列,条件为comm等于0
SELECT * FROM scott.emp WHERE comm = 0;
–查询scott用户的emp表的具有列,条件为comm等于空字符串
SELECT * FROM scott.emp WHERE comm = ”;
–查询scott用户的emp表的持有列,条件为comm等于空
SELECT * FROM scott.emp WHERE comm = NULL;
SELECT * FROM scott.emp WHERE comm IS NULL;
SELECT * FROM scott.emp WHERE comm IS NOT NULL;
SELECT empno,ename,sal,comm,(sal + comm,sal) * 12 FROM scott.emp;

/**
重点:NULL 空值
空值是指不可用,未分配的值
空值不等于零或空格
私自档次都能够支撑空值
回顾空值的任何算术表明式都相当空
*/
–查询scott用户的emp表的有所列
SELECT * FROM scott.emp;
–查询scott用户的emp表的兼具列,条件为comm等于0
SELECT * FROM scott.emp WHERE comm = 0;
–查询scott用户的emp表的全体列,条件为comm等于空字符串
SELECT * FROM scott.emp WHERE comm = ”;
–查询scott用户的emp表的富有列,条件为comm等于空
SELECT * FROM scott.emp WHERE comm = NULL;
SELECT * FROM scott.emp WHERE comm IS NULL;
SELECT * FROM scott.emp WHERE comm IS NOT NULL;
SELECT empno,ename,sal,comm,(sal + comm,sal) * 12 FROM scott.emp;

–nvl函数(Java的主意,传参数进去再次来到结果)
–nvl(第三个参数,第三个参数),借使第多个参数为null,则取第一个参数
SELECT empno,ename,sal,comm,NVL(sal + comm,sal) * 12 FROM scott.emp;

–nvl函数(Java的法子,传参数进去重回结果)
–nvl(第二个参数,第一个参数),要是第二个参数为null,则取第3个参数
SELECT empno,ename,sal,comm,NVL(sal + comm,sal) * 12 FROM scott.emp;

–定义字段的小名,注意,小名不协理接纳单引号
SELECT empno,ename,sal,sal * 12 AS yearsal FROM scott.emp;
SELECT empno,ename,sal,sal * 12 yearsal FROM scott.emp;
SELECT empno,ename,sal,sal * 12 AS “yearsal” FROM scott.emp;
皇冠现金app,SELECT empno,ename,sal,sal * 12 “yearsal” FROM scott.emp;
–查询规定:empno叫做columnName列名,eID叫做columnLable列标签(自个儿定义的外号)
SELECT empno AS eID,ename,sal,sal * 12 AS yearsal FROM scott.emp;
–JDBC中 getInt(String columnLable)
假使有外号则是别称,借使没有小名则columnLable正是小名

–定义字段的小名,注意,外号不支持选用单引号
SELECT empno,ename,sal,sal * 12 AS yearsal FROM scott.emp;
SELECT empno,ename,sal,sal * 12 yearsal FROM scott.emp;
SELECT empno,ename,sal,sal * 12 AS “yearsal” FROM scott.emp;
SELECT empno,ename,sal,sal * 12 “yearsal” FROM scott.emp;
–查询规定:empno叫做columnName列名,eID叫做columnLable列标签(本人定义的小名)
SELECT empno AS eID,ename,sal,sal * 12 AS yearsal FROM scott.emp;
–JDBC中 getInt(String columnLable)
假若有别称则是别称,假使没有小名则columnLable便是小名

–DISTINCT关键字明显的有分其他
–缺省情状下询问显示全体行,包含重复行
SELECT deptno FROM scott.emp;
–DISTINCT关键字去除重复数据
SELECT DISTINCT deptno FROM scott.emp;
–DISTINCT的功力范围是末端全部字段的结合
SELECT DISTINCT deptno,ename FROM scott.emp;
SELECT * FROM scott.emp;
SELECT DISTINCT deptno,job FROM scott.emp;
–为啥DISTINCT的效用范围是末端全体字段的组成
SELECT DISTINCT deptno,ename FROM scott.emp WHERE deptno = 30;
–DISTINCT
deptno之后比如三十五唯有一条记下,而30有五个ename,所以不可能浮现完整的多寡

–DISTINCT关键字鲜明的有分别的
–缺省景象下询问显示全数行,包涵重复行
SELECT deptno FROM scott.emp;
–DISTINCT关键字去除重复数据
SELECT DISTINCT deptno FROM scott.emp;
–DISTINCT的作用范围是前边全数字段的组合
SELECT DISTINCT deptno,ename FROM scott.emp;
SELECT * FROM scott.emp;
SELECT DISTINCT deptno,job FROM scott.emp;
–为何DISTINCT的意义范围是前面全数字段的结缘
SELECT DISTINCT deptno,ename FROM scott.emp WHERE deptno = 30;
–DISTINCT
deptno之后比如3二唯有一条记下,而30有5个ename,所以无法出示完整的数额

–where子句 限制筛选数据,必须跟在from之后
SELECT * FROM scott.emp WHERE deptno = 20 OR deptno = 30;
SELECT * FROM scott.emp WHERE deptno = 30 AND mgr = 7698;

–where子句 限制筛选数据,必须跟在from之后
SELECT * FROM scott.emp WHERE deptno = 20 OR deptno = 30;
SELECT * FROM scott.emp WHERE deptno = 30 AND mgr = 7698;

–相比运算符
SELECT * FROM scott.emp WHERE sal >= 800 AND sal <= 1600;
–between and
SELECT * FROM scott.emp WHERE sal BETWEEN 800 AND 1600;
–in 包蕴,in执行的时候会拆分成一堆的or
SELECT * FROM scott.emp WHERE deptno = 20 OR deptno = 30;
SELECT * FROM scott.emp WHERE deptno IN(20,30);
–like模糊查询 区分轻重缓急写
–%同盟全部 _同盟贰个字符
–查询全数以 “s” 开始的职员和工人
SELECT * FROM scott.emp WHERE ename LIKE ‘S%’;
–查询全体以”s”结尾的职工
SELECT * FROM scott.emp WHERE ename LIKE ‘%S’;
–查询名字中含有”S”的职工
SELECT * FROM scott.emp WHERE ename LIKE ‘%S%’;
–查询名字中第③个字符是A的员工
SELECT * FROM scott.emp WHERE ename LIKE ‘_A%’;

–相比较运算符
SELECT * FROM scott.emp WHERE sal >= 800 AND sal <= 1600;
–between and
SELECT * FROM scott.emp WHERE sal BETWEEN 800 AND 1600;
–in 包括,in执行的时候会拆分成一堆的or
SELECT * FROM scott.emp WHERE deptno = 20 OR deptno = 30;
SELECT * FROM scott.emp WHERE deptno IN(20,30);
–like模糊查询 区分轻重缓急写
–%协作全数 _匹配1个字符
–查询全体以 “s” 起首的职工
SELECT * FROM scott.emp WHERE ename LIKE ‘S%’;
–查询全部以”s”结尾的职员和工人
SELECT * FROM scott.emp WHERE ename LIKE ‘%S’;
–查询名字中富含”S”的职工
SELECT * FROM scott.emp WHERE ename LIKE ‘%S%’;
–查询名字中第3个字符是A的职员和工人
SELECT * FROM scott.emp WHERE ename LIKE ‘_A%’;

–优先级的规则 先and 再or
SELECT ename,job,sal
FROM scott.emp
WHERE job=’PERSIDENT’
OR job=’SALESMAN’
AND sal>1500;

–优先级的条条框框 先and 再or
SELECT ename,job,sal
FROM scott.emp
WHERE job=’PERSIDENT’
OR job=’SALESMAN’
AND sal>1500;

SELECT ename,job,sal
FROM scott.emp
WHERE job=’SALESMAN’
OR (job=’PERSIDENT’
AND sal>1500);

SELECT ename,job,sal
FROM scott.emp
WHERE job=’SALESMAN’
OR (job=’PERSIDENT’
AND sal>1500);

–order by 以…排序
–desc descend 降序
–asc ascend 升序
–对结果集排序 order by asc(升序 默许) desc(降序)
–注意:order by只能出现在sql语句的末段一行
–依照工资从低到高排序
SELECT * FROM scott.emp ORDER BY sal;
SELECT * FROM scott.emp ORDER BY sal asc;
SELECT * FROM scott.emp ORDER BY sal desc;

–order by 以…排序
–desc descend 降序
–asc ascend 升序
–对结果集排序 order by asc(升序 暗中同意) desc(降序)
–注意:order by只可以出现在sql语句的末梢一行
–遵照工资从低到高排序
SELECT * FROM scott.emp ORDER BY sal;
SELECT * FROM scott.emp ORDER BY sal asc;
SELECT * FROM scott.emp ORDER BY sal desc;