MySQL – Statements Reference
Here is the list of all important MySQL statements. Each statement has been explained along with suitable example.
Data Definition Statements
-
− This statement is used to change the characteristics of an existing database.
-
− This statement is used to change the characteristics of an existing event.
-
− This statement is used to change the characteristics of an existing function.
-
− This statement is used to change the characteristics of an existing procedure.
-
− This statement is used to change the characteristics of an existing server.
-
− This statement is used to change the characteristics of an existing table.
-
− This statement is used to change the characteristics of an existing tablespace.
-
− This statement is used to change the characteristics of an existing view.
-
− This statement is used to create a new database.
-
− This statement is used to create a new event.
-
− This statement is used to create a new function.
-
− This statement is used to create a new index.
-
− This statement is used to create a new procedure.
-
− This statement is used to create a new server.
-
− This statement is used to create a new spatial reference system.
-
− This statement is used to create a new table.
-
− This statement is used to create a new table space.
-
− This statement is used to create a new trigger.
-
− This statement is used to create a new view.
-
− This statement is used to delete an existing database.
-
− This statement is used to delete an existing event.
-
− This statement is used to delete an existing function.
-
− This statement is used to delete an existing index.
-
− This statement is used to delete an existing procedure.
-
− This statement is used to delete an existing server.
-
− This statement is used to delete an existing spacial reference system.
-
− This statement is used to delete an existing table.
-
− This statement is used to delete an existing table space.
-
− This statement is used to delete an existing trigger.
-
− This statement is used to delete an existing view.
-
− This statement is used to rename an existing table.
-
− This statement is used to remove all the records from a table.
Data Manipulation Statements
-
− This statement is used to call the stored procedure.
-
− This statement is use to remove records from a table.
-
− This statement is used execute MySQL statement.
-
− This statement is used to insert records into a table.
-
− This statement loads the contents of a file into a table.
-
− This statement is used to load the contents of an XML file into a table.
-
− This statement inserts a new record into a table. if you try to insert a new column with duplicate value for the column with UNIQUE or PRIMARY KEY constraints the old record will be completely replaced by the new record.
-
− This statement is used to retrieve rows from MySQL tables.
-
− A subquery is a query with in a query.
-
− This statement is used to retrieve the rows and columns of a specified table.
-
− This statement is used to update one or more records of an existing table.
-
− This statement is used to return a set of rows as a table.
-
− This statement is used to create common table expressions.
Transactional and Locking Statements
-
− This statement is used to start a transaction.
-
− This statement saves the changes in the current transaction.
-
− This statement undoes all changes till last commit.
-
− This statement is used to create a MySQL savepoint.
-
− This statement is used to set turn the auto-commit option on or off.
-
− This statement undoes all the changes done by the current transaction to the last named save point.
-
− This statement is used to release/delete the specified savepoint.
-
− This statement is used to create an instance level backup lock.
-
− This statement is used to release all backup locks in the current instance.
-
− This statement is used to acquire locks on MySQl tables.
-
− This statement is used to release locks on MySQl tables.
-
− This statement is used to set values to the characteristics of the current transaction.
Prepared Statements
-
− This is used to created a MySQL prepared statement.
-
− This is used to execute a MySQL prepared statement.
-
− This is used to delete an existing MySQL prepared statement.
Compound Statements
-
− The BEGIN … END syntax is used to create a compound statement.
-
− This statement is used to create labels for start and end blocks of compound statements.
-
− This statement is used to create Local variables, conditions, handlers and, Cursors..
-
− This statement is used to create user-defined variables or system variables with in Procedures.
Variables in Stored Programs
-
− This statement is used to declare local variables with in a compound statement or a function.
MySQL Flow Control Statements
-
− This statement is used to test a value for equality against a list of values/conditions.
-
− This executes a set of statements as long as the given condition is satisfied.
-
− This statement is used to restart the LOOP, REPEAT or, WHILE statements.
-
− This statement is used to exit the LOOP, REPEAT, WHILE statements or, BEGIN…END statements.
-
− This statement is used to execute a single or set of statements repeatedly.
-
− This statement is used to repeat the given set of statements (or statement) until the value of the given search condition is TRUE.
-
− This statement is used to end the stored functions.
-
− This statement is used to execute a single or set of statements repeatedly as long as the specified condition is TRUE.
MySQL Cursors Statements
-
− This statement is used to close a cursor.
-
− This statement is used to declare a MySQL cursor.
-
− This statement is used fetch the cursor declared earlier.
-
− This statement is used open the cursor declared earlier.
MySQL Condition Handling Statements
-
− This statement is used to declare a MySQL condition.
-
− This statement is used to declare a MySQL handler.
-
− The diagnostic area holds information about the errors occurred and information about the statements generated them.
-
− This statement is used to raise a warning or error. This is used within an error handler.
-
− The SIGNAL in MySQL is used provide error information to a handler, application or a client.
MySQL Account Management Statements
-
− This statement modify an existing MySQL user.
-
− This statement is used to create a MySQL role.
-
− This statement is used to create a MySQL user.
-
− This statement is used to drop an existing MySQL role.
-
− This statement is used to drop an existing MySQL user.
-
− This statement is used to grant privileges to a MySQL role or user.
-
− This statement is used to rename an existing user
-
− This statement is used to retrieve privileges previously granted to a MySQL role or user.
-
− This statement is used set a role as default.
-
− This statement is used to set a password to a MySQl user.
-
− This statement is used to set a role to a MySQl user.
MySQL Resource Group Management Statements
-
− This statement is used to modify an existing resource group.
-
− This statement is used to create a resource group.
-
− This statement is used to drop an existing a resource group.
-
− This statement is used to set/assign a thread to an existing MySQL resource group.
MySQL Table Maintenance Statements
-
− This statement is used to analyzes the specified table.
-
− This statement is used to check the integrity of database tables.
-
− This statement used to report checksum on the specified table.
-
− This statement is used to optimize a specified table.
-
− This statement is used to repair a corrupted table.
MySQL Miscellaneous Statements
-
− You can add user defined functions to MySQL server using this statement.
-
− You can drop a loadable user defined function using this statement.
-
− This statement is used to install MySQL component.
-
− This statement is used to install MySQL plugin.
-
− This statement is used to uninstall an existing MySQL component.
-
− This statement is used to uninstall an existing MySQL plugin.
-
− Using this statement you can clone from a remote server to a local directory.
-
− Using this statement you can set values to, user-defined variables, variables in procedures and, system variables.
-
− This statement is used to set value to the CHARACTER SET attribute.
-
− This statement Statement is used to set values to the character_set_client, character_set_connection, and character_set_results session system variables
MySQL SHOW Statements
-
− This statement displays the list of binary log files in the server.
-
− This statement displays the events in the specified binary log. In case if you haven’t specified a log name the first log is displayed.
-
− This statement displays the list of all the available character sets available in the current engine.
-
− This statement displays the list of collations supported by the server.
-
− This statement of MySQL is used to retrieve/display the description of all the columns of a table.
-
− This query shows/displays the statement used to create the specified database.
-
− This statement displays the query used to create the specified event.
-
− This displays the statement used to create the specified function.
-
− This query displays the statement used to create the specified procedure.
-
− This query shows/displays the statement used to create the specified table.
-
− This statement displays the CREATE statement used to create the specified trigger.
-
− This statement displays the CREATE statement used to create the specified user.
-
− This statement displays the CREATE VIEW statement used to create the specified view.
-
− This statement displays the list of databases in MySQL.
-
− This statement is a synonym for the SHOW DATABASES statement so, you can also use this statement to list out databases.
-
− This statement displays the operation information about the specified engine.
-
− This statement returns the current status information of the storage engines of MySQL.
-
− This statement is used to retrieve the information about the error occurred during the execution of the previous MySQL statement in the current session.
-
− This statement displays the list of events created in the current database.
-
− This statement returns the code in the form of a result set where, each row in it represents an instruction in the function.
-
− This statement displays the features of the specified stored function.
-
− This statement is used to display/ retrieve the privileges and roles assigned to a role or an account.
-
− This statement is used to list out the information about table index.
-
− This statement displays the lists the non-TEMPORARY tables which are currently open in the table cache.
-
− This statement displays the list of plugins currently installed in the MySQL server.
-
− This statement displays the list of privileges that are supported by the MYSQL server.
-
− This statement returns the code in the form of a result set where, each row in it represents an instruction in the procedure.
-
− This statement displays the features of the stored procedures.
-
− This statement displays the list of processes currently running on MySQL server.
-
− This statement displays the name and values of variables that gives you information about the server status.
-
− This statement displays the information about the non-TEMPORARY tables in a database.
-
− This statement is used to display information about all the triggers defined in the current database.
-
− This statement is used to display names and values of MySQL system variables.
-
− This statement is used to retrieve the information about the error, warnings, and notes occurred during the execution of the previous MySQL statement in the current session.
MySQL Other Administrative Statements
-
− Using this statement used to assign the indexes of a table to a key cache.
-
− Using this statement you can clear the caches of MySQL.
-
− Using this statement you can kill the specified thread.
-
− This statement is used to preload the index of a table into the default key cache or the cache assigned to it.
-
− This statement is used to reset various types of servers. Using this statement, you can reset a MySQL master, slave or, replica.
-
− Using this statement.
-
− This statement is used to stop and restart the MySQL server.
-
− This statement stops the MySQL server.
MySQL Utility Statements
-
− You can get the information about the table structure using this statement.
-
− Using this statement you can get the execution plan of the specified query.
-
− This statement is used to retrieve the information from the MySQL official documentation about the specified string.
-
− You can select/use an existing database using this statement.