Commands Cheat-Sheet - (MySQL Misc)
MySQL is a popular open-source relational database management system. It is widely used for building web applications and powering dynamic websites. In this cheat-sheet, we've compiled some common MySQL commands for various tasks.
Database Creation
To create a new database in MySQL, you can use the following command:
CREATE DATABASE dbname;
Replace dbname
with the name you want to give the new database.
Table Creation
To create a new table in MySQL, you can use the following command:
CREATE TABLE tablename (
column1 datatype,
column2 datatype,
column3 datatype
);
Replace tablename
with the name you want to give the new table and add the list of columns and their data types inside the parentheses.
Insert Data
To insert new data into a table in MySQL, you can use the following command:
INSERT INTO tablename (column1, column2, column3) VALUES (value1, value2, value3);
Replace tablename
with the name of the table and add the list of column names and their values inside the parentheses.
Select Data
To select data from a table in MySQL, you can use the following command:
SELECT column1, column2, column3 FROM tablename;
Replace tablename
with the name of the table and add the list of column names you want to select inside the SELECT
statement.
Update Data
To update data in a table in MySQL, you can use the following command:
UPDATE tablename SET column1 = value1, column2 = value2 WHERE condition;
Replace tablename
with the name of the table, and add the list of column names and their updated values inside the SET
statement. Also, specify the condition that should be met for the update to apply.
Delete Data
To delete data from a table in MySQL, you can use the following command:
DELETE FROM tablename WHERE condition;
Replace tablename
with the name of the table and specify the condition that should be met for the deletion to apply.
Important Points
- MySQL is a popular open-source relational database management system.
- Common commands for database creation, table creation, data insertion, selection, updating, and deletion have been discussed.
- Understanding these basic MySQL commands can help you get started with building web applications and powering dynamic websites.
Summary
In this cheat-sheet, we've compiled some common MySQL commands for various tasks like database creation, table creation, data insertion, selection, updating, and deletion. MySQL is a popular open-source relational database management system used widely for building web applications. Understanding these commands is essential for building dynamic websites.