insert into 语法(insert into作用)
在使用MySQL过程中,如果碰到需要备份一张业务的数据,很多人都会采取create table t select * from t1是这种方式,但是这种方式在生产上会造成巨大的危害,下面就细细分析。
备份的业务表如果是一张大表(t1),在t表未创建成功之前,t表会上MDL_EXCLUSIVE(X),这个时候,如果你执行use db或者TABLE STATUS命令时候,会发现,执行的命令被堵塞了,在5.7里还能查看到,堵塞的锁是MDL锁。
这是因为当执行use db时,会申请MDL_SHARED_HIGH_PRIO(SH)锁,这个锁与MDL_EXCLUSIVE(X)是不兼容的。所以才会导致堵塞。
解决方案:
create table t like t1;
insert into t select * from t1;
MySQl事务相关的语法
开启事务
1、begin
2、START TRANSACTION(推荐)
3、begin work
事务回滚:rollback
事务提交: commit
还原点:savepoint
show variables like '%autocommit%'; 自动提交事务是开启的
set autocommit=0;
insert into account values(5,5,5);
savepoint s1;
insert into account values(6,6,6);
savepoint s2;
insert into account values(7,7,7);
savepoint s3;
select * from account
rollback to savepoint s2
rollback
手指插入水杯天平还会平衡吗?(附验证结果
If you insert your finger into the water cup, will the balance keep balance?
一道简单又颇具争议的物理题,很多标称自己是'物理老师'的人都给出了错误答案。其实悬浮法经常用于测量材料密度,如辨别假玉,黄金等。
A simple and controversial physics problem, many people who call themselves' physics teachers' have given the wrong answer. In fact, the suspension method is often used to measure the density of materials, such as identifying fake jade, gold and so>
Crack your eggs into a medium mixing bowl. Add your milk or an equivalent amount of water to the eggs. Insert the pepper. Whisk all these ingredients together until the mixture is consistent throughout.
把鸡蛋打进碗里……搅拌,直到完全均匀。
The oracle was Aesop and his enduring, though somewhat incomplete, investment insight was “a bird in the hand is worth two in the bush.” To flesh out this principle, you must answer>
第1078天 英语超级写作奶爸,2.9年双语日记记录女儿生活
截止本篇:第16本
中英合计:92.2万字 英文36.7万字,中文55.5万字
云朵儿日记
第1078天 (2.9年)2020年11月25日 (三)
A Diary for My Yunduo’er
Day 1078, Nov 25, 2020 (Wed)
(节选)
......
...You made it your business to get up>
找到适合自己的人生轨迹 (汉英小故事)
一天,弟子们和禅师一起在田里插秧,可是弟子插的秧总是歪歪扭扭,而禅师却插得整整齐齐,就像是用尺子量过一样。
弟子们感到很疑惑,就问禅师:“师父,你是怎么把禾苗插得那么直的?”禅师笑着说:“其实很简单。你们在插秧的时候,眼睛要盯着一个东西,这样就能插直了。”于是,弟子们卷起裤管,高高兴兴地插完了一排秧苗,可是这次插的秧苗,竟成了一道弯曲的弧线。这是怎么回事呢?弟子很是不解。于是,禅师问弟子道:“你们是否盯住了一样东西?”“是呀,我盯住了那边吃草的水牛,那可是一个大目标啊!”弟子们答道。 禅师笑着说:“水牛边吃草边走,而你在插秧苗时也跟着水牛移动,这怎么能插直呢?”弟子们恍然大悟。这次,他们选定了远处的一棵大树。插完一看,插的秧果然都很直。
心语:做事要选定目标,但如何选择目标,选择怎样的目标也是关键。要想把事做成,就要选择正确、合理的目标。只有这样,才能更有效率地把事完成,实现既定的计划。
Find a suitable life path (Chinese English story)
One day, the disciples and the Zen master planted rice seedlings in the field together, but the seedlings planted by the disciples were always crooked, while the Zen master planted them neatly, as if measured with a ruler.
The disciples were puzzled and asked the Zen master, "master, how did you insert the seedlings so straight?" The Zen master smiled and said, "it's actually very simple. When you plant rice seedlings, keep your eyes>
2022-11-27:超过经理收入的员工。编写一个SQL查询来查找收入比经理高的员工。以下数据的结果输出是Joe,因为Joe是唯一挣得比经理多的雇员。
DROP TABLE IF EXISTS `employee`;
CREATE TABLE `employee` (
`id` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
`salary` int(11) NOT NULL,
`manager_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO `employee` VALUES ('1', 'Joe', '70000', '3');
INSERT INTO `employee` VALUES ('2', 'Henry', '80000', '4');
INSERT INTO `employee` VALUES ('3', 'Sam', '60000', null);
INSERT INTO `employee` VALUES ('4', 'Max', '90000', null);
#福大大架构师每日一题#





