icon

Learn Hub


Home   Html   Css   JavaScript   React js   C   C++   Python   MySQL  Java   Swift            

MySQL


Introduction to MySQL


MySQL is a very popular open-source relational database management system (RDBMS)

What is MySQL?



Database

Database is collection of data a format that can be easily accessed (digital)
A software application used to manage our DB is called DBMS (database management system )

Types of Database

  1. Relational
  2. Data stored in tables Ex: MySQL
  3. Non-Relational
  4. Data not stored in tables Ex:MongoDB


Types of datatypes in MySQL

Data type Description
CHAR(size) Holds a fixed length string (can contain letters, numbers, and special characters). The fixed size is specified in parenthesis. Can store up to 255 characters
VARCHAR(size) Holds a variable length string (can contain letters, numbers, and special characters). The maximum size is specified in parenthesis. Can store up to 255 characters. Note: If you put a greater value than 255 it will be converted to a TEXT type
TINYTEXT Holds a string with a maximum length of 255 characters
TEXT Holds a string with a maximum length of 255 characters
BLOB For BLOBs (Binary Large Objects). Holds up to 65,535 bytes of data
MEDIUMTEXT Holds a string with a maximum length of 16,777,215 characters
MEDIUMBLOB For BLOBS (Binary Large Objects). Holds up to 16,777,215 bytes of data
LONGTEXT Holds a string with a maximum length of 4,294,967,295 characters
LONGBLOB For BLOBS (Binary Large Objects). Holds up to 4,294,967,295 bytes of data
ENUM(x,y,z,etc.) Let you enter a list of possible values. You can list up to 65535 values in an ENUM list. If a value is inserted that is not in the list, a blank value will be inserted. Note: The values are sorted in the order you enter them. You enter the possible values in this format: ENUM('X','Y', 'Z')
SET Similar to ENUM except that SET may contain up to 64 list items and can store more than one choice


Types of MySQL Commands



Uses of commands

  1. SELECT :
  2. The SELECT statement is used to select data from a database.

    SELECT Syntax :
    SELECT column1, column2, ...
    FROM table_name;



  3. WHERE :
  4. The WHERE clause is used to filter records.

    WHERE Syntax :
    SELECT column1, column2, ...
    FROM table_name
    WHERE condition;



  5. INSERT INTO :
  6. The INSERT INTO statement is used to insert new records in a table.

    INSERT INTO Syntax :
    INSERT INTO table_name (column1, column2, column3, ...)
    VALUES (value1, value2, value3, ...);



  7. UPDATE :
  8. The UPDATE statement is used to modify the existing records in a table.

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



  9. DELETE :
  10. The DELETE statement is used to delete existing records in a table.

    DELETE Syntax :
    DELETE FROM table_name WHERE condition;



know more about MySQL