摘要: 数据类型分类: 1.number(x,y) 数字类型,x表示最大长度,y表示精度 2.varchar2(x) 可变字符串,x表示最大长度 3.char(x) 定长字符串,x表示最大长度 4.long 长字符串,最大2G 5.Date,日期(年月日时分秒) 6.TIMESTAMP 时间戳,精确到微秒要 阅读全文
posted @ 2019-04-19 21:23 ki1616 阅读(69) 评论(0) 推荐(0) 编辑
摘要: --用户管理--1.创建一个账户create user zhangsan identified by 123456;--2.修改账户的密码alter user zhangsan identified by 654321;--3.删除一个账户[cascade 表示是否级联删除]drop user zh 阅读全文
posted @ 2019-04-19 20:04 ki1616 阅读(46) 评论(0) 推荐(0) 编辑
摘要: --DML--insert关键字--作用:往表中一条(多条)记录--元祖(tuple)值式的插入(一次插入一条记录)--语法: insert into tablename(columnl,column1,...,columnN) values(vall,val1,...,valN)--例子:inse 阅读全文
posted @ 2019-04-19 19:39 ki1616 阅读(194) 评论(0) 推荐(0) 编辑
摘要: --查询10号部门中编号最新入职的员工,工龄最长的员工的个人信息 select e.* from emp e where e.hiredate in ((select max(e1.hiredate) from emp e1 where e1.deptno = 10), (select min(e2 阅读全文
posted @ 2019-04-19 19:14 ki1616 阅读(77) 评论(0) 推荐(0) 编辑
摘要: --查询部门名称SALES的员工信息 --两种方式 --sql 1992和sql 1999 --1992 --语法 /* select table.column, table2.column from table,table where table.column = table2.column2 w 阅读全文
posted @ 2019-04-19 19:14 ki1616 阅读(65) 评论(0) 推荐(0) 编辑
摘要: --数据分组 group by --作用:用于 对查询的数据进行分组,并处理 select deptno,job from emp group by deptno,job --1.分组之后,不能将除分组字段 之外的字段放在select后面 --2.group by 后面可以跟多个字段,则这多个字段值 阅读全文
posted @ 2019-04-19 19:10 ki1616 阅读(168) 评论(0) 推荐(0) 编辑
摘要: --数字函数 --abs 求取绝对值 select abs(-5) from dual; --ceil 向上取整 select ceil(3.1) from dual; --floor 向下取整 select floor(3.9) from dual; --round() 四舍五入 select r 阅读全文
posted @ 2019-04-19 19:09 ki1616 阅读(22) 评论(0) 推荐(0) 编辑
摘要: --转换函数 --to_date() select to_date('1999-12-12 12:12:12','YYYY-MM-DD HH24:MI:SS') from dual; --to_char() select to_char(sal,'$9999.00') from emp; --to_ 阅读全文
posted @ 2019-04-19 19:09 ki1616 阅读(54) 评论(0) 推荐(0) 编辑
摘要: --组函数 --avg --求20部门的平均薪水为多少? select avg(sal) avgsal from emp where deptno = 20 --sum --求20部门的员工的总薪水 select sum(sal) sumsal from emp where deptno = 20 阅读全文
posted @ 2019-04-19 19:09 ki1616 阅读(47) 评论(0) 推荐(0) 编辑
摘要: --计算字段 --不在于表中,通过+,-,*,操作和列进行计算得到的列 --获取员工的年薪 select ename,sal*12 from emp; select ename || sal*12 from emp; select ename || '的年薪为:'|| sal*12 from emp 阅读全文
posted @ 2019-04-19 19:07 ki1616 阅读(70) 评论(0) 推荐(0) 编辑
摘要: --单行函数 --1.字符函数 concat 拼接两个字符串数据 select ename||'的职位是'||job from emp; select concat( ename,'的职位是')job from emp; select concat(concat( ename,'的职位是'),job 阅读全文
posted @ 2019-04-19 19:07 ki1616 阅读(55) 评论(0) 推荐(0) 编辑
摘要: 日期函数 --sysdate 返回系统当前日期,没有括号 select sysdate from dual; --add_months(d1,d2) select add_months(hiredate,6) from emp; select add_months(sysdate,6) from d 阅读全文
posted @ 2019-04-19 19:07 ki1616 阅读(53) 评论(0) 推荐(0) 编辑
摘要: --order by 关键字 --作用:用于对查询结果进行排序 select * from emp where deptno = 20 order by sal --1.如何决定升序还是降序? select * from emp where deptno = 20 order by sal asc 阅读全文
posted @ 2019-04-19 19:06 ki1616 阅读(64) 评论(0) 推荐(0) 编辑
摘要: --where关键字 select ename,job,sal from emp; --例:查询工资大于2000的员工信息 select * from emp where sal >2000 -- =,!=,<>,<,>,<=,>=,any,some,all --查询员工信息,条件:薪水要大于100 阅读全文
posted @ 2019-04-19 17:46 ki1616 阅读(61) 评论(0) 推荐(0) 编辑