20180208 accumulation

Temporary tables are similar to permanent tables, except that temporary tables are stored in tempdb and are automatically dropped when they are no longer used.

There are two types of temporary tables: local and global. They differ in name, visibility, and availability. The names of local temporary tables begin with a single number sign (#); they are only visible to the current user connection; they are dropped when the user disconnects from the SQL Server instance. A global temporary table, whose name begins with two number signs (##), is visible to any user after creation, and is dropped when all users referencing the table disconnect from SQL Server.

For example, if the employees table is created, any user with security permissions to use the table in the database can use the table unless it is dropped. If the database session creates a local temporary table #employees, only the session can use the table, and the table is dropped when the session is disconnected. If the ##employees global temporary table is created, it can be used by any user in the database. If the table is not used by other users after you create it, the table is dropped when you disconnect. If another user is using the table after you create it, SQL Server will drop it when you disconnect and all other sessions are no longer using the table.

A problem I encountered today is can the as alias be used in the insert into and update and delete statements in mysql? I'm still looking at it, but I found some useful knowledge when I looked up the data. I'd like to share it with you, that is, about the execution order of sql and MySQL statements:

The execution order of sql and mysql shows that the internal mechanism is the same. The biggest difference is in the reference to the alias. 

1. sql execution order (1) from  (3) join  (2) on  (4) where  (5) group by (begin to use the alias in select, which can be used in subsequent statements) (6) avg, sum.. ..  (7) having  (8) select  (9) distinct  (10) order by  From this order, it is not difficult to find that all query statements are executed from from. During the execution process, each step will be The next step generates a virtual table that will be used as input to the next execution step. Step 1: First perform a Cartesian product on the first two tables in the from clause, and then generate a virtual table vt1 (select a relatively small table as the base table)  Step 2: The next step is to apply the on filter, The logical expression in on will be applied to each row in vt1, the rows that satisfy the logical expression of on will be filtered out, and the virtual table vt2 will be generated.  Step 3: If it is an outer join, then this step will add an outer row, and the left outer jion will Add the left table filtered in the second step, if it is a right outer join, then add the rows filtered out of the right table in the second step, so that the virtual table vt3 is generated.  Step 4: If the from clause The number of tables is more than two tables, then vt3 and the third table are connected to calculate the Cartesian product to generate a virtual table. This process is a process of repeating 1-3 steps, and finally a new virtual table vt3 is obtained.  
















Step 5: Apply the where filter, reference the where filter to the virtual table produced in the previous step, and generate the virtual table vt4. There is a more important detail here that I have to say. For the query containing the outer join clause, there are A confusing question, whether to specify logical expressions in the on filter or the where filter? The biggest difference between on and where is that if a logical expression is applied in on, the removed rows can be added back in the third step of outer join, and the removal of where is final. For a simple example, there is a student table (class, name) and a grade table (name, grade), I now need to return the grades of all students in a class x, but there are several students in this class who are absent, that is Says there is no record in the grade sheet. In order to get our expected results, we need to specify the relationship between students and grades in the on clause (student.name=grades.name), then do we find that when the second step is performed, the records of students who did not take the test are not will appear in vt2, because they are filtered out by the logical expression of on, but we can use left outer join to get back the students in the left table (students) who did not take the test, because we want to return the x class For all students in on , if you apply student.class='x' in on, left outer join will retrieve all records of students in class x (thanks to netizen Kang Qinmou __Kang Qinmiao 's correction ) , so it can only be used in where filter is applied in student.class='x' because its filtering is final. 
Step 6: The group by clause combines the unique values ​​in a group to get the virtual table vt5. If group by is applied, then all subsequent steps can only get vt5 columns or aggregate functions (count, sum, avg, etc.). The reason is that the final result set contains only one row for each group. Please keep this in mind. 
Step 7: Apply the cube or rollup options to generate a supergroup for vt5 and generate vt6. 
第八步:应用having筛选器,生成vt7。having筛选器是第一个也是为唯一一个应用到已分组数据的筛选器。 
第九步:处理select子句。将vt7中的在select中出现的列筛选出来。生成vt8. 
第十步:应用distinct子句,vt8中移除相同的行,生成vt9。事实上如果应用了group by子句那么distinct是多余的,原因同样在于,分组的时候是将列中唯一的值分成一组,同时只为每一组返回一行记录,那么所以的记录都将是不相同的。 
第十一步:应用order by子句。按照order_by_condition排序vt9,此时返回的一个游标,而不是虚拟表。sql是基于集合的理论的,集合不会预先对他的行排序,它只是成员的逻辑集合,成员的顺序是无关紧要的。对表进行排序的查询可以返回一个对象,这个对象包含特定的物理顺序的逻辑组织。这个对象就叫游标。正因为返回值是游标,那么使用order by 子句查询不能应用于表表达式。排序是很需要成本的,除非你必须要排序,否则最好不要指定order by,最后,在这一步中是第一个也是唯一一个可以使用select列表中别名的步骤。 
第十二步:应用top选项。此时才返回结果给请求者即用户。 

二、mysql的执行顺序 
SELECT语句定义 
一个完成的SELECT语句包含可选的几个子句。SELECT语句的定义如下: 
SQL代码 

 

[java]   view plain  copy
  1. <SELECT clause> [<FROM clause>] [<WHERE clause>] [<GROUP BY clause>] [<HAVING clause>] [<ORDER BY clause>] [<LIMIT clause>]   
SELECT子句是必选的,其它子句如WHERE子句、GROUP BY子句等是可选的。 
一个SELECT语句中,子句的顺序是固定的。例如GROUP BY子句不会位于WHERE子句的前面。 

SELECT语句执行顺序 
SELECT语句中子句的执行顺序与SELECT语句中子句的输入顺序是不一样的,所以并不是从SELECT子句开始执行的,而是按照下面的顺序执行: 
开始->FROM子句->WHERE子句->GROUP BY子句->HAVING子句->ORDER BY子句->SELECT子句->LIMIT子句->最终结果 
每个子句执行后都会产生一个中间结果,供接下来的子句使用,如果不存在某个子句,就跳过 
对比了一下,mysql和sql执行顺序基本是一样的, 标准顺序的 SQL 语句为: 

 

 

[html]   view plain  copy
  1. select 考生姓名, max(总成绩) as max总成绩   
  2.   
  3. from tb_Grade   
  4.   
  5. where 考生姓名 is not null   
  6.   
  7. group by 考生姓名   
  8.   
  9. having max(总成绩) > 600   
  10.   
  11. order by max总成绩   
 在上面的示例中 SQL 语句的执行顺序如下: 

   (1). 首先执行 FROM 子句, 从 tb_Grade 表组装数据源的数据 

   (2). 执行 WHERE 子句, 筛选 tb_Grade 表中所有数据不为 NULL 的数据 

   (3). 执行 GROUP BY 子句, 把 tb_Grade 表按 "学生姓名" 列进行分组(注:这一步开始才可以使用select中的别名,他返回的是一个游标,而不是一个表,所以在where中不可以使用select中的别名,而having却可以使用,感谢网友  zyt1369  提出这个问题)

   (4). 计算 max() 聚集函数, 按 "总成绩" 求出总成绩中最大的一些数值 

   (5). 执行 HAVING 子句, 筛选课程的总成绩大于 600 分的. 

   (7). 执行 ORDER BY 子句, 把最后的结果按 "Max 成绩" 进行排序. 

服务器的ssh安全性如何。(平台安全性)
数据库有没有加密。(依赖服务安全性)
代码设计、登录、鉴权分组是否合理。(应用层安全性)
有没有把秘钥上传到git上。(管理安全性)!

MyBatis的Mapper映射文件是如何与对应的接口相关联的 60

public interface UserDao 实现类里面应该有写selectUserByUsernameAndPassword这个ID的。你到实现类里面看看。
比如:getSqlMapClientTemplate().queryForList(“selectUserByUsernameAndPassword
”);如果加了命名空间namespace,那么语句是这样getSqlMapClientTemplate().queryForList(“命名空间名称.selectUserByUsernameAndPassword
 
DataX是一个让你方便的在异构数据源之间交换数据的离线同步框架/工具,实现了在任意的数据处理系统之间的数据交换,目前DataX在淘宝内部每天约有5000道同步任务分布在全天各个时段,平均每天同步数据量在2-3TB。

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326026255&siteId=291194637