KEMBAR78
MySQL Basic Commands CheatSheet | PDF
0% found this document useful (0 votes)
14 views3 pages

MySQL Basic Commands CheatSheet

This document is a cheat sheet for basic MySQL commands, covering essential operations such as creating tables, inserting and retrieving data, filtering, updating, and deleting records. It also includes commands for altering tables, renaming, counting rows, using aggregate functions, joining tables, and managing databases. The document serves as a quick reference for users working with MySQL databases.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views3 pages

MySQL Basic Commands CheatSheet

This document is a cheat sheet for basic MySQL commands, covering essential operations such as creating tables, inserting and retrieving data, filtering, updating, and deleting records. It also includes commands for altering tables, renaming, counting rows, using aggregate functions, joining tables, and managing databases. The document serves as a quick reference for users working with MySQL databases.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Basic MySQL Commands Cheat Sheet

1. Create Table

CREATE TABLE table_name (


column1 datatype PRIMARY KEY,
column2 datatype,
...
);

2. Insert Data

INSERT INTO table_name (column1, column2, ...)


VALUES (value1, value2, ...);

3. Retrieve Data

SELECT * FROM table_name;


SELECT column1, column2 FROM table_name;

4. Filter Data

SELECT * FROM table_name WHERE condition;


SELECT * FROM table_name WHERE age > 18 AND grade = 'A';

5. Update Data

UPDATE table_name
SET column1 = value1, column2 = value2
WHERE condition;

6. Delete Data

DELETE FROM table_name WHERE condition;

7. Alter Table
Basic MySQL Commands Cheat Sheet

ALTER TABLE table_name ADD column_name datatype;


ALTER TABLE table_name MODIFY column_name new_datatype;
ALTER TABLE table_name DROP COLUMN column_name;

8. Rename Table

RENAME TABLE old_table_name TO new_table_name;

9. Distinct Values

SELECT DISTINCT column_name FROM table_name;

10. Count Rows

SELECT COUNT(*) FROM table_name;

11. Aggregate Functions

SELECT MAX(column_name), MIN(column_name), AVG(column_name), SUM(column_name)


FROM table_name;

12. Joining Tables

SELECT a.column1, b.column2


FROM table1 a
JOIN table2 b ON a.common_column = b.common_column;

13. Drop Table

DROP TABLE table_name;

14. Create Database and Use It

CREATE DATABASE database_name;


USE database_name;
Basic MySQL Commands Cheat Sheet

15. Show and Describe

SHOW TABLES;
DESCRIBE table_name;

You might also like