当前位置:网站首页>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面试】第一时间阅读,回复【资料】获取福利,回复【项目】获取项目源码,回复【简历模板】获取简历模板,回复【学习路线图】获取学习路线图。
边栏推荐
- What is multimodal interaction?
- File system and directory operations
- This connection is not a private connection this website may be pretending to steal your personal or financial information
- 圆心科技,很焦虑?
- Oculus quest2 development: (I) basic environment construction and guide package
- Paging query, using jdbc-- paging query
- 【Paper】2013_ An efficient model predictive control scheme for an unmanned quadrotor helicopter
- Qos(Quality of Service)
- harbor api 2.0查询
- Redis实现短信登入功能(二)Redis实现登入功能
猜你喜欢

Method of applying for code signing certificate by enterprise

Sectigo certificate

This connection is not a private connection this website may be pretending to steal your personal or financial information

Issue SSL certificate with IP address

Cheap SSL certificate abroad

Beanfactory creation process

On mask culling of unity

Create transfer generation point

【Paper】2019_ Distributed Cooperative Control of a High-speed Train

【Paper】2013_ An efficient model predictive control scheme for an unmanned quadrotor helicopter
随机推荐
Bean creation process and lazy init delay loading mechanism
Is the Flink connector JDBC open source? Where can I download it
The most comprehensive summary notes of redis foundation + advanced project in history
This connection is not a private connection this website may be pretending to steal your personal or financial information
On mask culling of unity
[control] multi agent system summary. 4. control agreement.
力扣59. 螺旋矩阵 II
Arsenal Stadium Tour - take you to the front and back of Arsenal Stadium
[UAV] gyroscope data analysis, taking Victor intelligent jy901b as an example
Moore Manor diary I: realize the reclamation, sowing, watering and harvest in Moore Manor
Difference between request forwarding and redirection
Implementation of one interview question one distributed lock every day
Break through the existing customer group marketing, and try customer grouping management (including clustering model and other practical effect evaluation)
Winter vacation parent-child tour, these new york attractions are not only fun but also knowledge
[FPGA] IIC读写EEPROM 的实现
Enlist soldiers and generals, draw small programs, multi-threaded display time
SCM learning notes: interrupt learning
BeanFactory创建流程
Unity enables simple music visualization
Check London attractions suitable for parents and children in winter vacation