Course
Statements Reference
MySQL Tutorial
This SQL tutorial is structured for beginners to guide them from the foundational concepts to advanced data manipulation and querying techniques in SQL. By the end of this tutorial, you will have developed a robust understanding of SQL, equipping you with the knowledge to efficiently manage and analyze data across various database systems. This guide sets the stage for your growth into a skilled data professional, ready to tackle complex data challenges and contribute to the field of data analysis and database management.
Statements Reference
Here is the list of all important MySQL statements. Each statement has been explained along with suitable example.
Data Definition Statements
- MySQL ALTER DATABASE Statement − This statement is used to change the characteristics of an existing database.
- MySQL ALTER EVENT Statement − This statement is used to change the characteristics of an existing event.
- MySQL ALTER FUNCTION Statement − This statement is used to change the characteristics of an existing function.
- MySQL ALTER PROCEDURE Statement − This statement is used to change the characteristics of an existing procedure.
- MySQL ALTER SERVER Statement − This statement is used to change the characteristics of an existing server.
- MySQL ALTER TABLE Statement − This statement is used to change the characteristics of an existing table.
- MySQL ALTER TABLESPACE Statement − This statement is used to change the characteristics of an existing tablespace.
- MySQL ALTER VIEW Statement − This statement is used to change the characteristics of an existing view.
- MySQL CREATE SPATIAL REFERENCE SYSTEM Statement − This statement is used to create a new spatial reference system.
- MySQL DROP SPATIAL REFERENCE SYSTEM Statement − This statement is used to delete an existing spacial reference system.
Data Manipulation Statements
- MySQL LOAD XML Statement − This statement is used to load the contents of an XML file into a table.
- MySQL REPLACE Statement − 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.
- MySQL TABLE Statement − This statement is used to retrieve the rows and columns of a specified table.
- MySQL UPDATE Statement − This statement is used to update one or more records of an existing table.
Transactional and Locking Statements
- MySQL Set Auto-commit Statement − This statement is used to set turn the auto-commit option on or off.
- MySQL ROLLBACK TO SAVEPOINT Statement − This statement undoes all the changes done by the current transaction to the last named save point.
- MySQL RELEASE SAVEPOINT Statement − This statement is used to release/delete the specified savepoint.
- MySQL LOCK INSTANCE FOR BACKUP Statement − This statement is used to create an instance level backup lock.
- MySQL UNLOCK INSTANCE Statement − This statement is used to release all backup locks in the current instance.
- MySQL SET TRANSACTION Statement − This statement is used to set values to the characteristics of the current transaction.
Prepared Statements
Compound Statements
- MySQL BEGIN ... END Compound Statement − The BEGIN ... END syntax is used to create a compound statement.
- MySQL Statement Labels − This statement is used to create labels for start and end blocks of compound statements.
- MySQL DECLARE Statement − This statement is used to create Local variables, conditions, handlers and, Cursors..
- MySQL Variables in Stored Programs − This statement is used to create user-defined variables or system variables with in Procedures.
Variables in Stored Programs
- MySQL Local Variable DECLARE Statement − This statement is used to declare local variables with in a compound statement or a function.
MySQL Flow Control Statements
- MySQL CASE Statement − This statement is used to test a value for equality against a list of values/conditions.
- MySQL IF Statement − This executes a set of statements as long as the given condition is satisfied.
- MySQL LEAVE Statement − This statement is used to exit the LOOP, REPEAT, WHILE statements or, BEGIN…END statements.
- MySQL REPEAT Statement − This statement is used to repeat the given set of statements (or statement) until the value of the given search condition is TRUE.
- MySQL WHILE Statement − This statement is used to execute a single or set of statements repeatedly as long as the specified condition is TRUE.
MySQL Cursors Statements
MySQL Condition Handling Statements
- MySQL GET DIAGNOSTICS Statement − The diagnostic area holds information about the errors occurred and information about the statements generated them.
- MySQL RESIGNAL Statement − This statement is used to raise a warning or error. This is used within an error handler.
- MySQL SIGNAL Statement − The SIGNAL in MySQL is used provide error information to a handler, application or a client.
MySQL Account Management Statements
- MySQL REVOKE Statement − This statement is used to retrieve privileges previously granted to a MySQL role or user.
MySQL Resource Group Management Statements
- MySQL ALTER RESOURCE GROUP Statement − This statement is used to modify an existing resource group.
- MySQL SET RESOURCE GROUP Statement − This statement is used to set/assign a thread to an existing MySQL resource group.
MySQL Table Maintenance Statements
MySQL Miscellaneous Statements
- MySQL CREATE FUNCTION Statement for User-Defined Functions − You can add user defined functions to MySQL server using this statement.
- MySQL DROP FUNCTION Statement for User-Defined Functions − You can drop a loadable user defined function using this statement.
- MySQL UNINSTALL COMPONENT Statement − This statement is used to uninstall an existing MySQL component.
- MySQL CLONE Statement − Using this statement you can clone from a remote server to a local directory.
- MySQL SET Syntax for Variable Assignment − Using this statement you can set values to, user-defined variables, variables in procedures and, system variables.
- MySQL SET CHARACTER SET Statement − This statement is used to set value to the CHARACTER SET attribute.
- MySQL SET NAMES Statement − 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
- MySQL SHOW BINARY LOGS Statement − This statement displays the list of binary log files in the server.
- MySQL SHOW BINLOG EVENTS Statement − 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.
- MySQL SHOW CHARACTER SET Statement − This statement displays the list of all the available character sets available in the current engine.
- MySQL SHOW COLLATION Statement − This statement displays the list of collations supported by the server.
- MySQL SHOW COLUMNS Statement − This statement of MySQL is used to retrieve/display the description of all the columns of a table.
- MySQL SHOW CREATE DATABASE Statement − This query shows/displays the statement used to create the specified database.
- MySQL SHOW CREATE EVENT Statement − This statement displays the query used to create the specified event.
- MySQL SHOW CREATE FUNCTION Statement − This displays the statement used to create the specified function.
- MySQL SHOW CREATE PROCEDURE Statement − This query displays the statement used to create the specified procedure.
- MySQL SHOW CREATE TABLE Statement − This query shows/displays the statement used to create the specified table.
- MySQL SHOW CREATE TRIGGER Statement − This statement displays the CREATE statement used to create the specified trigger.
- MySQL SHOW CREATE USER Statement − This statement displays the CREATE statement used to create the specified user.
- MySQL SHOW CREATE VIEW Statement − This statement displays the CREATE VIEW statement used to create the specified view.
- MySQL SHOW SCHEMAS Statement − This statement is a synonym for the SHOW DATABASES statement so, you can also use this statement to list out databases.
- MySQL SHOW ENGINE Statement − This statement displays the operation information about the specified engine.
- MySQL SHOW ENGINES Statement − This statement returns the current status information of the storage engines of MySQL.
- MySQL SHOW ERRORS Statement − This statement is used to retrieve the information about the error occurred during the execution of the previous MySQL statement in the current session.
- MySQL SHOW EVENTS Statement − This statement displays the list of events created in the current database.
- MySQL SHOW FUNCTION CODE Statement − This statement returns the code in the form of a result set where, each row in it represents an instruction in the function.
- MySQL SHOW FUNCTION STATUS Statement − This statement displays the features of the specified stored function.
- MySQL SHOW GRANTS Statement − This statement is used to display/ retrieve the privileges and roles assigned to a role or an account.
- MySQL SHOW OPEN TABLES Statement − This statement displays the lists the non-TEMPORARY tables which are currently open in the table cache.
- MySQL SHOW PLUGINS Statement − This statement displays the list of plugins currently installed in the MySQL server.
- MySQL SHOW PRIVILEGES Statement − This statement displays the list of privileges that are supported by the MYSQL server.
- MySQL SHOW PROCEDURE CODE Statement − This statement returns the code in the form of a result set where, each row in it represents an instruction in the procedure.
- MySQL SHOW PROCEDURE STATUS Statement − This statement displays the features of the stored procedures.
- MySQL SHOW PROCESSLIST Statement − This statement displays the list of processes currently running on MySQL server.
- MySQL SHOW STATUS Statement − This statement displays the name and values of variables that gives you information about the server status.
- MySQL SHOW TABLE STATUS Statement − This statement displays the information about the non-TEMPORARY tables in a database.
- MySQL SHOW TRIGGERS Statement − This statement is used to display information about all the triggers defined in the current database.
- MySQL SHOW VARIABLES Statement − This statement is used to display names and values of MySQL system variables.
- MySQL SHOW WARNINGS Statement − 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
- MySQL CACHE INDEX Statement − Using this statement used to assign the indexes of a table to a key cache.
- MySQL LOAD INDEX INTO CACHE Statement − This statement is used to preload the index of a table into the default key cache or the cache assigned to it.
- MySQL RESET Statement − This statement is used to reset various types of servers. Using this statement, you can reset a MySQL master, slave or, replica.
MySQL Utility Statements
- MySQL DESCRIBE Statement − You can get the information about the table structure using this statement.
- MySQL EXPLAIN Statement − Using this statement you can get the execution plan of the specified query.
- MySQL HELP Statement − This statement is used to retrieve the information from the MySQL official documentation about the specified string.