Oracle SQL advanced programming learning notes (I) Core SQL statement 1, select statement execution sequence
5 SELECT <column list> 1 FROM <source object list> 1.1 FROM <left source object > <join type > JOIN <right source object> ON <on predicates>2 WHERE <where predicates>3 GROUP BY <group by expressions>4 HAVING
(1) first execute the clause or link clause after the From clause to query the initial dataset. (2) execute the where clause to streamline the initial result set, query the dataset that meets the where condition from the initial dataset. (3) execute the group by clause to aggregate and group the result set from and where query. (4) HAVING clause, in the preceding result set, the condition in the clause is queried as a real dataset. (5) SELECT statement, the columns to be displayed in the final result set are returned. (6) order by clause, sort the queried data sets. Pay attention to the data volume during sorting. If the data volume is small, sort the data in the memory. If the data volume is large, use the temporary disk space, therefore, the data size during sorting is very important. 2. Insert statements to Insert multiple tables
INSERT ALL WHEN <condition1> THEN INTO <table1> WHEN<condition2> THEN INTO <table2> .................................. SELECT <column list> FROM ........
Pay attention to the when condition when using the mark capture query to avoid repeated insertion into multiple tables. 3. The MERGE statement can obtain the dataset to be updated or inserted into the table based on conditions, and then update the table from one or more sources or insert rows into the table.
MERGE