My SQL

SQL stands for Structured Query Language, it's a computer language to store, retrieve and query the data from Relational Database.

Multiple Vendors have created their own database software system to store data such as MySQL, MS Access, Oracle, Sybase, Informix, Postgres and SQL Server etc, all of them use SQL or some variation of it as database language.

MySQL is one of the widely used Relational Database Management Systems (RDBMS). the latest version of MySQL is 8.29. Community Edition of MySQL is free and open-source, it can be used for small and large applications.

RDBMS

RDBMS stands for Relational Database Management System, all SQL queries run on RDBMS. an RDBMS contains a database and tables and the system provides a relation between them.

Table

The core of the storage of RDBMS is a table, it consists of ROW and COLUMN, all the data in RDBMS is actually stored in single or multiple tables.

Row

A row or Record is an individual entry of the table. It's the horizontal entity in the table.

Column

A column is a verticle entity of the table that contains all information of a specific field of a particular row.

SQL

All SQL commands can be categorized into 4 main groups.

  • Data Definition Language
  • Data Manipulation Language
  • Data Control Language
  • Data Query Language

Data Definition Language

Data Definition Language or DDL is a group of commands which describe the schema or structure of a database or table.

  • CREATE : Create command is used to create a new database, a table, or a view of a table in the database
  • ALTER : Alter command is used to modify an existing table or column.
  • DROP : The drop command is used to delete a database, a table, or a column

Data Manipulation Language

Data Manipulation Language or DML is a group of commands which can change or manipulate the existing database or table.

  • INSERT : Insert command is used to create or insert a new record in the table
  • UPDATE : The update command is used to update or modify existing records in the table
  • DELETE : Deletes Command is used to delete or remove records from a table

Data Control Language

Data Control Language or DCL is a group of commands which controls the access of data to the user.

  • GRANT : The Grand command is used to give a privilege or permission to the user to access the data
  • REVOKE : The Revoke command is used to take the privileges or permissions back from the user

Data Query Language

Data Query Language or DQL is used to query the database and records.

  • SELECT : The Select command is used to retrieve the records from single or multiple tables

latest version of MySQL can be downloaded from https://dev.mysql.com/doc/

Get Information about MySQL

select current user

SELECT USER();

select the current version of MySQL

SELECT VERSION();

select current date

SELECT CURDATE();

select current time

SELECT CURTIME();

select the current date-time

SELECT CURRENT_DATE();

select current time

SELECT CURRENT_TIME();

select current timestamp

SELECT CURRENT_TIMESTAMP();

MySQL query is Letter Case Agnostic, Uppercase and Lowercase both are Valid

MySQL can also be used as a calculator to perform simple calculations such as

SELECT 4 + 1;

to complex mathematical equations such as

SELECT SIN(PI()/4), (4+1)*5;

follow us on