当前位置:网站首页>Mysql07 (data update DML)
Mysql07 (data update DML)
2022-07-22 01:24:00 【Happy learning】
In the actual project , The most used is the read operation , But inserting data is as important as deleting data , There are relatively few modifications
/*
The insert :
Insertion of tuple values
Insertion of query results
*/
-- The most basic way to insert
--insert into tablename values(val1,val2,....) If there is no column after the table name , Then you can only insert all columns
--insert into tablename(col1,col2,...) values(val1,val2,...) You can specify which columns to insert data into
insert into emp values(2222,'haha','clerk',7902,to_date('2019-11-2','YYYY-MM-dd'),1000,500,10);
select * from emp;
-- When inserting data into some columns , You don't just insert into which column you want to insert , Follow the specifications defined when creating the table
insert into emp(empno,ename) values(3333,'wangwu')
-- Other ways to create tables
-- Copy table and copy table data at the same time , Constraints are not copied
create table emp2 as select * from emp;
-- Copy table structure but not table data , Constraints are not copied
create table emp3 as select * from emp where 1=2;
-- If there is a set of data , If you insert all the data in the set one by one , How efficient ? Generally in actual operation , Rarely insert... One by one , It's more of a batch insert
/*
Delete operation :
delete from tablename where condition
*/
-- Delete data that meets the criteria
delete from emp2 where deptno = 10;
-- Clear the data of the whole table
delete from emp2;
--truncate , Follow delete Somewhat different ,delete In the process of deletion, the transaction , and truncate No business , Once deleted, it is permanently deleted , No rollback operation
-- High efficiency , However, it is prone to misoperation , So it's not recommended
truncate table emp2
/*
Modify the operating :
update tablename set col = val1,col2 = val2 where condition;
One or more columns can be modified
*/
-- Update single column
update emp set ename = 'heihei' where ename = 'hehe';
-- Update the values of multiple columns
update emp set job='teacher',mgr=7902 where empno = 15;
/*
Adding, deleting and modifying is a common operation of database , When operating, you need 《 Business 》 Guarantee , That is to say, every time in pl/sql In the implementation of sql After the statement, you need to complete commit The operation of
Affairs become very critical :
The main purpose is to ensure data consistency
If the same data , Only one person can visit at a time , There will be no data confusion , But in the current project , More concurrent access
Concurrent access brings insecurity of data , That is, inconsistency
If we want to ensure the security of data , The main way is to lock ,MVCC
Extension of business :
The most basic database transactions
Declarative transactions
Distributed transactions
In order to improve efficiency , It is possible that multiple operations will be performed in the same transaction , Then it may be partially successful , Department failure , Based on this situation, transaction control is needed .
select * from emp where id = 7902 for update
select * from emp where id = 7902 lock in share mode.
If you don't guarantee things , It will cause dirty reading , It can't be read repeatedly , Fantasy reading .
*/
边栏推荐
- JS get the server IP, port and protocol
- 多智能体系统集群协同控制实验平台详解与典型案例
- NetworkX的基本用法
- 连接远程服务器的vscode无法格式化代码/文档(已解决)
- mysql数据恢复
- Visualization: you must know these ten data visualization tool software platforms
- 44: Chapter 4: develop file service: 5: integrate fastdfs in [files] file service to realize the logic of [upload avatar]; (including: integrating fastdfs in the project; cross domain issues; creating
- list解析<stl初级> (跑路人笔记)
- 【学习笔记】AGC008
- uniapp 使用 u-view 框架小程序的样式问题集合
猜你喜欢
随机推荐
Allure测试报告怎么设置
2022年化工自动化控制仪表考试试题模拟考试平台操作
一种新的UI测试方法:视觉感知测试
Cannot open source file < stdio. in CUDA file h>
网络 IO 模型的演化过程
docker搭建redis及集群
Strategies for implementing steam school-based curriculum system
malloc 和 空間配置器
ModuleNotFoundError: No module named ‘pysat.solvers‘(已解决)
Laike can optical transceiver solves the problem of fire networking of linked fire engines such as Fu'an fs5216/fs5116
逍遙管理器安裝
Diversified system to carry out maker education activities
47: Chapter 4: developing file services: 8: automatic image review (Alibaba cloud content security); (don't read it if you haven't written it yet; to be written...)
JS get the server IP, port and protocol
Explore the interest in robot maker Education
uniapp,微信小程序input正则校验只能输入为数字和小数点位数限制
(pytorch进阶之路六)Swin Transformer实现
Lecture 1 Overview
Oracle sets the maximum number of connections
How to understand pointers?