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, filter out the rows that satisfy the logical expression of on, and generate virtual table vt2  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. As 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. 
Step 8: Apply the having filter to generate vt7. The having filter is the first and only filter applied to grouped data. 
Step 9: Process the select clause. Filter out the columns that appear in the select in vt7. Generate vt8. 
Step 10: Apply distinct clause, remove the same row in vt8, generate vt9. In fact, distinct is redundant if the group by clause is applied, also because, when grouping, the unique values ​​in the column are grouped into groups, and only one row of records is returned for each group, then all records will be not the same. 
Step 11: Apply the order by clause. Sort vt9 according to order_by_condition, and return a cursor instead of a virtual table. sql is based on the theory of sets, the set does not pre-order his rows, it is just a logical set of members, the order of the members is irrelevant. A query that sorts a table can return an object that contains a logical organization in a specific physical order. This object is called a cursor. Because the return value is a cursor, queries using the order by clause cannot be applied to table expressions. Sorting is expensive. Unless you must sort, it is best not to specify order by. Finally, this step is the first and only step that can use aliases in the select list. 
Step 12: Apply the top option. At this time, the result is returned to the requester, that is, the user. 

Second, the execution order of mysql SELECT statement defines  a completed SELECT statement contains several optional clauses. The SELECT statement is defined as follows:  SQL code  


 

[java] view plaincopy    
  1. <SELECT clause> [<FROM clause>] [<WHERE clause>] [<GROUP BY clause>] [<HAVING clause>] [<ORDER BY clause>] [<LIMIT clause>]   
SELECT clause is mandatory, other clauses such as WHERE clause, GROUP BY clause, etc. are optional. 
In a SELECT statement, the order of clauses is fixed. For example, the GROUP BY clause does not come before the WHERE clause. 

The execution order  
of the SELECT statement The execution order of the clauses in the SELECT statement is different from the input order of the clauses in the SELECT statement, so it is not executed from the SELECT clause, but in the following order:  
start -> FROM sub Sentence->WHERE clause->GROUP BY clause->HAVING clause->ORDER BY clause->SELECT clause->LIMIT clause->final result  
After each clause is executed, an intermediate result will be generated for connection The following clauses are used. If there is no clause, skip  
the comparison. The execution order of mysql and sql is basically the same. The standard order of SQL statements is: 

 

 

[html] view plaincopy    
  1. select candidate name, max(total score) as max total score   
  2.   
  3. from tb_Grade   
  4.   
  5. where candidate name is not null   
  6.   
  7. group by candidate name   
  8.   
  9. having max(total grade)  >  600   
  10.   
  11. order by max total score   
 The order of execution of the SQL statements in the above example is as follows: 

   (1). First execute the FROM clause, assemble the data of the data source from the tb_Grade table 

   (2). Execute the WHERE clause to filter all data in the tb_Grade table that are not NULL 

   (3). Execute the GROUP BY clause, and group the tb_Grade table by the "student name" column ( Note: You can use the alias in select only at the beginning of this step, it returns a cursor, not a table, so where You cannot use the alias in select, but having can be used. Thanks to netizen   zyt1369   for raising this question)

   (4). Calculate the max() aggregate function, and press "total score" to find the largest values ​​in the total score 

   (5). Execute the HAVING clause, and filter courses with a total score greater than 600 points. 

   (7). Execute the ORDER BY clause, and sort the final result by "Max score". 

How secure is the server's ssh. (Platform Security)
Is the database encrypted. (depending on service security)
Whether the code design, login, and authentication grouping are reasonable. (Application Layer Security)
Did you upload the key to git? (Management Security)!

How the Mapper mapping file of MyBatis is associated with the corresponding interface 60

The public interface UserDao implementation class should have the ID selectUserByUsernameAndPassword written in it. You look inside the implementation class.
比如:getSqlMapClientTemplate().queryForList(“selectUserByUsernameAndPassword
"); If the namespace namespace is added, then the statement is like this getSqlMapClientTemplate().queryForList(" namespace name.selectUserByUsernameAndPassword
 
DataX is an offline synchronization framework/tool ​​that allows you to easily exchange data between heterogeneous data sources. It realizes data exchange between arbitrary data processing systems. Currently, DataX has about 5,000 synchronization tasks distributed in Taobao every day. At various times throughout the day, the average daily data synchronization volume is 2-3TB.

Guess you like

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