SQLG
SQLG
the optimizer):
The following query answers the request, “find all rows in table t1 that also exist in table t2”:
SELECT column1,column2,column3
FROM t1
WHERE (column1,column2,column3) IN
(SELECT column1,column2,column3 FROM t2);
Columns selected for output can be referred to in ORDER BY and GROUP BY clauses using
column names, column aliases, or column positions. Column positions are integers and begin
with 1
SELECT college, region, seed FROM tournament
ORDER BY 2, 3;
The HAVING clause can refer to aggregate functions, which the WHERE clause cannot:
SELECT user, MAX(salary) FROM users
GROUP BY user HAVING MAX(salary) > 10;
MySQL supports the following JOIN syntax for the table_references part
each other). In standard SQL, they are not equivalent. INNER JOIN is used with
query FROM clause. For example, a subquery in a SELECT statement FROM clause is a derived
table:
SELECT ... FROM (subquery) [AS] tbl_name ...
Indexes can be used for views processed using the merge algorithm. However, a view
that is processed with the temptable algorithm is unable to take advantage of indexes
on its underlying tables (although indexes can be used during generation of the
temporary tables).
You can use DROP TABLE or ALTER TABLE to drop or alter a table that is used in a view
Aliases for column names in the SELECT statement are checked against the maximum
column length of 64 characters (not the maximum alias length of 256 characters).
ORDER BY is permitted in a view definition, but it is ignored if you select from a view using a
schedule:
AT timestamp [+ INTERVAL interval] ...
| EVERY interval
[STARTS timestamp [+ INTERVAL interval] ...]
[ENDS timestamp [+ INTERVAL interval] ...]
interval:
quantity {YEAR | QUARTER | MONTH | DAY | HOUR | MINUTE |
WEEK | SECOND | YEAR_MONTH | DAY_HOUR | DAY_MINUTE |
DAY_SECOND | HOUR_MINUTE | HOUR_SECOND | MINUTE_SECOND}
This statement creates and schedules a new event. The event will not run unless the Event
Scheduler is enabled.
index_option:
KEY_BLOCK_SIZE [=] value
| index_type
| WITH PARSER parser_name
| COMMENT 'string'
| {VISIBLE | INVISIBLE}
index_type:
USING {BTREE | HASH}
algorithm_option:
ALGORITHM [=] {DEFAULT | INPLACE | COPY}
lock_option:
LOCK [=] {DEFAULT | NONE | SHARED | EXCLUSIVE}
The best way to improve the performance of SELECT operations is to create indexes on one
or more of the columns that are tested in the query. The index entries act like pointers to
the table rows, allowing the query to quickly determine which rows match a condition in
the WHERE clause, and retrieve the other column values for those rows. All MySQL data types
can be indexed.
Although it can be tempting to create an indexes for every possible column used in a query,
unnecessary indexes waste space and waste time for MySQL to determine which indexes to
use. Indexes also add to the cost of inserts, updates, and deletes because each index must
be updated. You must find the right balance to achieve fast queries using the optimal set of
indexes.
Indexes are used to find rows with specific column values quickly. Without an index, MySQL
must begin with the first row and then read through the entire table to find the relevant rows.
The larger the table, the more this costs. If the table has an index for the columns in question,
MySQL can quickly determine the position to seek to in the middle of the data file without
having to look at all the data. This is much faster than reading every row sequentially.
index_type:
USING {BTREE | HASH}
algorithm_option:
ALGORITHM [=] {DEFAULT | INPLACE | COPY}
lock_option:
LOCK [=] {DEFAULT | NONE | SHARED | EXCLUSIVE}