MySQL - All Commands Cheat Sheet

MySQL - All Commands Cheat Sheet

A B C D E F G I L O R S T U

A

ALTER DATABASE The ALTER DATABASE command modifies the attributes or configuration settings of an existing database.
ALTER EVENT The ALTER EVENT command in MySQL modifies the behavior and properties of an existing event.
ALTER FUNCTION ALTER FUNCTION modifies the definition of an existing function.
ALTER PROCEDURE The ALTER PROCEDURE command in MySQL allows for the modification of an existing stored procedure by adding, removing, or modifying its parameters, local variables, and SQL statements.
ALTER TABLE ALTER TABLE modifies the structure or settings of an existing MySQL table.
ALTER TRIGGER The ALTER TRIGGER command is used to modify an existing trigger in a MySQL database.
ALTER USER ALTER USER modifies user accounts in a MySQL database, including their privileges, password, roles, and other attributes.
ALTER VIEW ALTER VIEW alters the definition of an existing view in the current database.

B

BACKUP TABLE The BACKUP TABLE command in MySQL provides a mechanism to create a snapshot of a MySQL table and store it as a backup file on the server's local file system.
BEGIN The BEGIN command in MySQL initiates a transaction that groups multiple database operations together.

C

CHECK TABLE CHECK TABLE inspects a table to detect and report any discrepancies, errors, or inconsistencies within its structure or data.
COMMIT The COMMIT command in MySQL finalizes a transaction.
CREATE DATABASE CREATE DATABASE creates a new database within the MySQL server.
CREATE EVENT The CREATE EVENT command in MySQL is used to create and schedule the execution of an event at specific intervals.
CREATE FUNCTION CREATE FUNCTION creates a stored function in the current database for use in SQL statements.
CREATE INDEX The CREATE INDEX command in MySQL is used to create an index on a table column.
CREATE PROCEDURE The CREATE PROCEDURE command allows the creation of stored procedures in MySQL.
CREATE TABLE The CREATE TABLE command in MySQL creates a new table in a database.
CREATE TRIGGER CREATE TRIGGER defines a database trigger, a special type of stored procedure that automatically executes when a specific event occurs on a table (e.g., insert, update, delete).
CREATE USER The CREATE USER command creates a new user in the MySQL database.
CREATE VIEW The CREATE VIEW command in MySQL allows you to create a virtual table, or "view," that is derived from one or more existing tables.

D

DELETE FROM DELETE FROM removes rows from a database table that meet specific criteria.
DESCRIBE DESCRIBE provides metadata about a table or query result, including its columns, data types, and any indexes or constraints.
DROP DATABASE The DROP DATABASE command in MySQL permanently removes a specified database from the server.
DROP EVENT DROP EVENT permanently removes an event from the MySQL database.
DROP FUNCTION DROP FUNCTION removes a previously created stored or user-defined function from the MySQL database.
DROP INDEX DROP INDEX can be used in conjunction with other MySQL commands, such as ALTER TABLE and CREATE INDEX.
DROP PROCEDURE
DROP TABLE DROP TABLE is a command used to permanently remove a table and all its data from a MySQL database.
DROP TRIGGER DROP TRIGGER removes a trigger from a database.
DROP USER DROP USER permanently removes a user account from the MySQL database server.
DROP VIEW The DROP VIEW command in MySQL removes a previously created database view.

E

EXPLAIN The EXPLAIN command provides detailed information about the execution plan chosen by MySQL to execute a given query.

F

FLUSH PRIVILEGES The FLUSH PRIVILEGES command in MySQL is used to force the server to reload the grant tables into memory.

G

GRANT GRANT authorizes privileges to specific users or roles on MySQL database objects like tables, views, or procedures.

I

INSERT INTO INSERT INTO is a MySQL command used to add a new row or rows to a table.

L

LOAD DATA INFILE LOAD DATA INFILE is a powerful MySQL command that enables the efficient ingestion of data from delimited text files, known as input files, into MySQL tables.
LOCK TABLES LOCK TABLES is used to acquire exclusive or shared locks on one or more tables in a MySQL database.

O

OPTIMIZE TABLE OPTIMIZE TABLE is a MySQL command used to optimize the performance of a table by rebuilding its internal structure and reorganizing its data for faster access.

R

RELEASE SAVEPOINT RELEASE SAVEPOINT releases a previously created savepoint.
RENAME TABLE The RENAME TABLE command in MySQL allows you to change the name of an existing table.
RENAME USER The RENAME USER command in MySQL is used to change the username for an existing user account in the database.
REPAIR TABLE REPAIR TABLE is a MySQL command used to check and repair damaged tables in a database.
RESET QUERY CACHE The RESET QUERY CACHE command in MySQL allows users to clear the query cache, which stores the results of previously executed queries for faster retrieval.
RESTORE TABLE The RESTORE TABLE command in MySQL is used to restore the data and structure of a database table from a previously created backup.
REVOKE
ROLLBACK ROLLBACK reverses all database changes made within the current transaction and returns the database to the state it was in before the transaction began.

S

SAVEPOINT SAVEPOINT is a transactional control command in MySQL used to mark a specific point within a transaction, allowing you to later roll back or release changes made after that point.
SELECT The SELECT command in MySQL retrieves data from one or more relational database tables.
SET AUTOCOMMIT The SET AUTOCOMMIT command controls whether autocommit mode is enabled or disabled for the current session.
SET NAMES The SET NAMES command allows you to specify the character set for the client connection.
SET PASSWORD The SET PASSWORD command modifies the password for the MySQL server user account specified in the syntax.
SHOW COLUMNS SHOW COLUMNS is a versatile command in MySQL used to display detailed information about the columns in a specified table.
SHOW CREATE TABLE SHOW CREATE TABLE displays the SQL statement used to create a specified table, including its schema, indexes, and constraints.
SHOW CREATE VIEW The SHOW CREATE VIEW command in MySQL provides a detailed description of a specified view's definition and structure.
SHOW DATABASES The SHOW DATABASES command displays a list of all databases that the current MySQL user has access to.
SHOW ERRORS SHOW ERRORS displays the last n errors generated by the MySQL server.
SHOW GRANTS
SHOW INDEX SHOW INDEX is a fundamental MySQL command utilized to display detailed information about indices defined on a specific table.
SHOW PROCESSLIST SHOW PROCESSLIST is a MySQL command that provides real-time information about all running threads and their activities within the database.
SHOW PROFILES The SHOW PROFILES command in MySQL provides insights into query performance by displaying profiling information for executed queries.
SHOW STATUS The SHOW STATUS command in MySQL displays the current status and values of system variables, connection information, and thread statistics.
SHOW TABLES The SHOW TABLES command in MySQL is used to list the names of all tables in the current database.
SHOW VARIABLES SHOW VARIABLES displays the values of configurable system variables and session variables.
SHOW WARNINGS The SHOW WARNINGS command in MySQL displays any warnings that have occurred during the execution of the previous statement or the most recent command.
START TRANSACTION START TRANSACTION initiates a new database transaction.

T

TRUNCATE TABLE TRUNCATE TABLE is a powerful command used to swiftly remove all rows from a table, effectively emptying it without affecting the table's structure or its indices.

U

UNLOCK TABLES
UPDATE The UPDATE command modifies existing rows in a specified table by setting one or more column values.
USE The USE command in MySQL is used to switch to a specific database within the current MySQL session.