当前位置:网站首页>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面试】第一时间阅读,回复【资料】获取福利,回复【项目】获取项目源码,回复【简历模板】获取简历模板,回复【学习路线图】获取学习路线图。
边栏推荐
- 一条命令运行rancher
- PBR material: basic principle and simple fabrication
- 0 basic unity course. Bricklaying
- Connect to the database and run node JS running database shows that the database is missing
- Servlet lifecycle
- Enter the date format string as the production date of the commodity, and enter the shelf life (days); Calculate the number of days until today before the expiration date of the product. 1. Change the
- Qos(Quality of Service)
- Using the command line to convert JSON to dart file in fluent
- Redis implements SMS login function (II) redis implements login function
- Marvel fan welfare: Singapore Madame Tussauds Wax Museum Marvel 4D experience Museum
猜你喜欢

Unity script life cycle and execution sequence

PBR material: basic principle and simple fabrication

Collective system

How to renew an SSL certificate

BeanFactory创建流程

为什么win10开热点后电脑没有网络?
![[UAV] kinematic analysis from single propeller to four rotor UAV](/img/32/1a88b102f832ffbbc1a7e57798260a.jpg)
[UAV] kinematic analysis from single propeller to four rotor UAV

Arsenal Stadium Tour - take you to the front and back of Arsenal Stadium

Connect to the database and run node JS running database shows that the database is missing

Why does the computer have no network after win10 is turned on?
随机推荐
Deep learning ----- different methods to realize inception-10
Efficiency test of adding and querying ArrayList and LinkedList
The most comprehensive summary notes of redis foundation + advanced project in history
圆心科技,很焦虑?
【Paper】2017_ Distributed control for high-speed trains movements
Redis实现短信登入功能(一)传统的Session登入
深度学习------不同方法实现Inception-10
【Paper】2013_ An efficient model predictive control scheme for an unmanned quadrotor helicopter
一条命令运行rancher
Redis implements SMS login function (I) traditional session login
One interview question a day the difference between B tree and b+ tree
2021-03-16
Unreal 4 unavigationsystemv1 compilation error
Unity realizes rotation and Revolution
Create transfer generation point
IO stream, character read / write, copy
Detailed explanation of cookies and sessions
Keywords implements and @override
Meet in Bangkok for a romantic trip on Valentine's Day
The subsystem implementing transaction persistence in DBMS is ()