当前位置:网站首页>Oracle-数据的基本操作
Oracle-数据的基本操作
2022-06-30 04:51:00 【旷世奇才李先生】
工欲善其事必先利其器
文章持续更新,可以微信搜索【小奇JAVA面试】第一时间阅读,回复【资料】获取福利,回复【项目】获取项目源码,回复【简历模板】获取简历模板,回复【学习路线图】获取学习路线图。

文章目录
一、备份数据库表
create table 备份后的表名称 as (要备份的数据)
1、备份学生表并命名为student_bak
create table student_bak as select * from student;
二、数据增加
1、向学生表中插入“张三”学生的数据
insert into student (id,name,age,sex,class) values (10,'张三',20,'男','五班');
三、数据修改
1、将学生名称为“张三”的学生的年龄修改为20
update student set age = 20 where name = '张三';
四、数据删除
1、将学生名称为“张三”的学生信息删除
delete from student where name = '张三';
五、事务处理
oracle在执行增删改操作的时候都需要进行提交事务的,增删改操作是先将数据放入缓存区,执行commit命令后才能真正的修改数据,在缓存区的时候可以使用rollback命令进行回滚操作
1、将学生名称为“张三”的学生信息删除
delete from student where name = '张三';
此时并没有真正的删除学生的数据,需要commit提交后才能修改数据,所以可以将上面的语句和commit语句写成一个语句,为了简便我之前的操作都没有加commit命令。
delete from student where name = '张三';
commit;
六、数据伪列
数据伪列是oracle数据库默认的一些列,如果不主动操作是没有什么影响,如果要使用这些伪列可以显示的操作,例如之前的sysdate系统日期,现在来讲一下rownum(行号)、rowid(不重复的行号)
1、查询所有的学生姓名和行号
select rownum,name from student;
2、查询所有的学生姓名和行号并取出第一行
select rownum,name from student where rownum = 1;
3、查询所有的学生姓名和行号并取出前五行
select rownum,name from student where rownum <= 1;
使用rownum是行号,可以被修改,这样的话就有可能重复,所以我们一般删除的时候可以根据rowid来进行删除操作。假设我们数据库中有两个姓名为“张三”的数据,我们想删除其中一条应该怎么删除呢,如果用where name=‘张三’,这样的话肯定两条都删除了,那我们应该使用rowid来操作
4、删除学生表中学生姓名为“张三”的重复数据
delete from student where rowid not in (select min((rowid)from student where name = '张三')
七、总结
这里的相关内容还没有整理完毕,文章后面持续更新,建议收藏。
文章中涉及到的命令大家一定要像我一样每个都敲几遍,只有在敲的过程中才能发现自己对命令是否真正的掌握了。
可以微信搜索【小奇JAVA面试】第一时间阅读,回复【资料】获取福利,回复【项目】获取项目源码,回复【简历模板】获取简历模板,回复【学习路线图】获取学习路线图。
边栏推荐
- How to repair expired SSL certificates?
- [UAV] gyroscope data analysis, taking Victor intelligent jy901b as an example
- Unity is associated with vs. there is a compiler problem when opening
- Introduction to some representations, neighbors and degrees of Graphs
- Sailing experience not to be missed in New York Tourism: take you to enjoy the magnificent city scenery from different perspectives
- Draw on screen border in Commodore 64
- 圆心科技,很焦虑?
- 力扣2049:统计最高分的节点数目
- Free travel recommendation in Bangkok: introduction to the Mekong River in Bangkok
- Marvel fan welfare: Singapore Madame Tussauds Wax Museum Marvel 4D experience Museum
猜你喜欢

力扣589:N 叉树的前序遍历

Qos(Quality of Service)

深度学习------不同方法实现Inception-10

SCM learning notes: interrupt learning

【Paper】2019_ Consensus Control of Multiple AUVs Recovery System Under Switching Topologies and Time D

Unreal 4 unavigationsystemv1 compilation error

Bean creation process and lazy init delay loading mechanism

Oculus quest2 development: (I) basic environment construction and guide package

Recommended cultural landmarks of these tourist attractions in Bangkok

Redis实现短信登入功能(二)Redis实现登入功能
随机推荐
A virtual reality secret room escape adventure, let you see Technology Singapore
Circle center technology, very anxious?
Qos(Quality of Service)
Steamvr causes abnormal scene camera
Redis implements SMS login function (II) redis implements login function
Detailed explanation of cookies and sessions
This connection is not a private connection this website may be pretending to steal your personal or financial information
Unity3d lookat parameter description
Qos(Quality of Service)
Unreal 4 unavigationsystemv1 compilation error
Redis实现短信登入功能(二)Redis实现登入功能
Foreign SSL certificate
brew安装nvm报nvm command not found解决方案
Static keyword
Collective system
Window10 jar double click to run without response
EasyRecovery数据恢复软件 恢复了我两年前的照片视频数据
為什麼win10開熱點後電腦沒有網絡?
【Paper】2017_ Research on coordinated control method of underwater vehicle formation marine survey
[UAV] kinematic analysis from single propeller to four rotor UAV