Oracle基本操作知识点(2)

一、数据库的导入导出

--全导出:

exp 登录名/密码@数据库名称 file = 路径\文件的名称.dmp full = y;

---指定表导出:

exp 登录名/密码@数据库名称 file = 路径\文件的名称.dmp tables=(table1,teble2...)

--导出指定表的指定数据:

exp 登录名、密码@数据库名称 file=路径、文件名.dmp tables=(table) query=\"where条件\"

--导入 如果对已经存在的表导入不报错 在命令后面加上 ignore=y: 

imp 登录名、密码@数据库名称 file=路径、文件名.dmp ignore=y

--不同用户之间的导入:

imp 登录名、密码@数据库名称 fromuser=导出用户名 touser=导入用户 file=路径\文件.dmp

二、条件查询

1、精确查询(=)

--查询性别是女生的学生信息

例: select * from t_student where sex = '2';

2、模糊查询(%)

例:

--查询名字最后一位是8 的学生信息

select * from t_student where name like '%8';

--查询密码用123开头的学生信息

select * from t_student where password like '123%';

--查询名字含有8 的学生信息

select * from t_student where name like '%8%';

三、运算符

1、算术运算符(+ 、- 、* 、/ 、mod(取模))

例:

--计算语文、英语、数学三科成绩总和。

select (s.chinese + s.math + s.english) 总分 from t_score s

--计算语文、英语、数学三科成绩平均成绩

select (s.chinese + s.math + s.english)/3 平均成绩 from t_score s

2、--比较运算符( '>' ,'<' ,'>=' ,'<=' ,'=' ,'!=' ,'<>' , between...and...)

①--查询年龄大于13且小于等于18的学生】

select * from t_student s where s.age > 13 and s.age <=18;

② --查询身高在1.60m(含)到1.80m(含)的学生(两种方法,最后使用between......and(当查询的量达到一定数量时,效率更高))

select * from t_student s where s.height >=160 and s.height <=180;

select * from t_student s where s.height between 160 and 180;

③ --查询性别不是男的老师信息

select * from t_teacher t where t.sex != 1;

④--当查询内容不连续的时候用in 不能用or

--in

--查询语文分数是80 ,85,86,88的学号及语文分数

select o.student_no, o.chinese from t_score o where o.chinese in (80,85,88,86);

--not like 不等、不像

--查询非南宁的学生

select * from t_student t where t.address not like '%南宁%';

3、--to_char ,to_date ,to_number

①--to_char:是把时间或者数字转换为字符串

例:to_char(时间,‘yyyy-mm-dd’)

②--to_date:是把值转换为数据库中的日期类型

 例:to_date('1990-08-09','yyyy-mm-dd')

③--to_number:把值转换成number类型

4、--集合运算符:把两个或以上的结果集合成一个结果的运算

①--union :集合合并 去除重复的记录,只留下不存在重复且重复中的一条(对应列的数据类型必须一致)

例:

--查询性别为1的学生信息

--查询ID为1,4,5,6,8,10 的学生记录

select id,name,birthday,age from t_student t where t.sex=1

union

select id,name,birthday,age from t_student t where t.id in(1,4,5,6,8,10);

②--union all :集合合并 所有集合的记录数相加,不去除任何一条

例:

--查询性别为1的学生信息

--查询ID为1,4,5,6,8,10 的学生记录

select id,name,birthday,age from t_student t where t.sex=1

union all

select id,name,birthday,age from t_student t where t.id in(1,4,5,6,8,10);

③--intersect :集合的交集 去掉不重复的只留下重复的记录

例:

select id,name,birthday,age from t_student t where t.sex='1'

intersect

select id,name,birthday,age from t_student t where t.id in(1,4,5,6,8,10);

④--minus (数学中的补集) 集合相减 ,把重复的全部去掉只留下第一个集合中不重复的记录

例:

例:
select id,name,birthday,age from t_student t where t.sex='1'

minus

select id,name,birthday,age from t_student t where t.id in(1,4,5,6,8,10);

#想要例题中的数据表的,可以私聊。。。。。。。。。。。。。感谢观看!!!#

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Life_Now

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值