Introduction: SQL
SQL, or Sequenced Query Language, is a domain-specific language used in RDBMS to communicate with the database.
Uses:
To perform Data Query: SQL statements can be used to retrieve certain or desired information from the database
To perform Data Manipulation: SQL statements can be used to add, delete, sort, or any other modification required in the data value of the database
To Protect Data: SQL statements can define the security of the data, allowing restrictions in the database access system.
To Define Data: SQL
Based on the uses of SQL statements, there are four main categories of SQL:
Data Definition Language (DDL)
Data Manipulation Language (DML)
Data Query Language (DQL)
Data Control Language (DCL)
DDL (Data Definition Language)
Data Definition Language (DDL) are the SQL statements that are used to define the database schemas. DDL, mostly:
CREATE database: used to create a database.
DROP database: used to delete a database.
ALTER database: used to modify a database or the structure/table of a database.
TRUNCATE database: used to remove the contents from a table, including spaces.
COMMENT: used to add comments in a query to provide information to the users.
RENAME: used to rename an element in a database.
DML (Data Manipulation Language)
Data Manipulation Language (DML) is used to for the manipulation of the data in a database.
INSERT INTO ... : used to Insert or Add new data in a database.
DELETE: used to delete records from a database table.
UPDATE: used to modify or update database table.
DELETE ... FROM ...: used to remove or delete records from a database.
DQL (Data Query Language)
Data Query Language (DQL) is used to perform queries on a database.
SELECT ... FROM ... : used to retrieve data from a database.
DCL (Data Control Language)
Data Control Language (DCL) contains statements that deals with the data security, such as permission to use, and control the database.
GRANT: used to provide an access privilege to a database user.
REVOKE: used to withdraw the user's access privilege.
** MySQL != SQL **
MySQL is a RDBMS. It is a software system that allows user to store and utilize the data appropriately. The data handling in MySQL is performed using a query programming language, called SQL.