What are the different types of MYSQL commands?
MySQL commands can be broadly categorized into several types based on their functionality. Here's an overview of the different types of MySQL commands:
Data Definition Language (DDL) Commands:
CREATE: Used to create a new database or table.
CREATE DATABASE database_name;
CREATE TABLE table_name (column1 datatype, column2 datatype, ...);
ALTER: Modifies an existing database or table.
ALTER TABLE table_name ADD column_name datatype;
ALTER TABLE table_name MODIFY column_name datatype;
DROP: Deletes an existing database, table, or index.
DROP DATABASE database_name;
DROP TABLE table_name;
Data Manipulation Language (DML) Commands:
SELECT: Retrieves data from one or more tables.
SELECT column1, column2 FROM table_name WHERE condition;
INSERT: Adds new rows to a table.
INSERT INTO table_name (column1, column2) VALUES (value1, value2);
UPDATE: Modifies existing records in a table.
UPDATE table_name SET column1 = value1 WHERE condition;
DELETE: Removes rows from a table based on a condition.
DELETE FROM table_name WHERE condition;
Data Query Language (DQL) Commands:
- SELECT: Used to query the database and retrieve specific information.
Data Control Language (DCL) Commands:
GRANT: Provides specific privileges to database objects.
GRANT privilege ON object TO user;
REVOKE: Removes specific privileges from database objects.
REVOKE privilege ON object FROM user;
Transaction Control Commands:
START TRANSACTION: Begins a new transaction.
START TRANSACTION;
COMMIT: Saves the changes made during the current transaction.
COMMIT;
ROLLBACK: Undoes the changes made during the current transaction.
ROLLBACK;
Data Administration Commands:
SHOW: Displays information about databases, tables, columns, etc.
SHOW DATABASES;
SHOW TABLES;
DESCRIBE or EXPLAIN: Shows the structure of a table.
DESCRIBE table_name;
These are some of the fundamental types of MySQL commands used for various database operations. Each type of command serves a specific purpose in managing and manipulating data within a MySQL database.
Comments
Post a Comment