Microsoft Word - Sam's Teach Yourself MySQL in 21 Days - SAMS.doc

(singke) #1
Example:
OPTIMIZE TABLE Customers

REPLACE


[LOW_PRIORITY or DELAYED] [INTO] table_name [(column_list)] VALUES(value_list),
REPLACE [LOW_PRIORITY or DELAYED] [INTO] table_name [(column_list)] SELECT ...,
REPLACE [LOW_PRIORITY or DELAYED] [INTO] table_name SET column_name =
expression[, SET column_name = expression] ...
This statement is identical to the INSERT statement, and has all the same options as the INSERT
statement. The only difference is that this statement will delete a record before it is inserted if the old
record has the same value in a unique index.


Example:
REPLACE INTO Customers (Customer_ID, First_Name) VALUES(12, "Jason")

REVOKE


privilege_list ON database_object FROM user_name
The REVOKE statement takes away the privileges given in the GRANT statement.
The grant tables must be reloaded for any changes to take effect. See the FLUSH command.
See the GRANT statement for the privilege list.
The following example takes away all privileges for the user mark at localhost. It does not delete the
user from the MySQL grant tables.


Example:
REVOKE ALL PRIVILEGES ON *.* FROM mark@localhost

SELECT


[DISTINCT]column_list [INTO OUTFILE 'file_name' export_options] FROM table_list
[{CROSS or INNER or STRAIGHT or LEFT or NATURAL} JOIN table name [ON join
condition]], [WHERE criteria][GROUP BY column names][HAVING criteria][ORDER BY
column names]


This statement will return a resultset based on the criteria provided.
The DISTINCT keyword will return only unique values from a given column.
The clauses after the WHERE clause provide additional filtering.

Example:
SELECT * FROM Customers WHERE Last_Name
LIKE "Paul%"
ORDER BY Last_Name

SHOW


parameter
The SHOW statement returns a resultset based on the parameter provided. The following are the
allowable parameters:
ƒ COLUMNS FROM table_name [FROM database_name]


or
ƒ COLUMNS FROM database_name.table_name Provides a detailed
list of information based on the table name
ƒ DATABASES Shows a list of databases
ƒ GRANTS FOR user_name Displays the privilege information
for the given user.
ƒ INDEX FROM table_name Returns information on all the
indexes in a table
ƒ PROCESSLIST Shows a list of processes and IDs that are
currently running
ƒ STATUS Shows server status variables
ƒ TABLES FROM database_name Shows the list of tables in a
database
ƒ TABLE STATUS FROM database_name Shows a detailed account
of the actions taken in a table
ƒ VARIABLES Provides a list of system variables
Free download pdf