SQL is a standard language for accessing and manipulating databases.
What is SQL?
- SQL stands for Structured Query Language
- SQL lets you access and manipulate databases
- SQL became a standard of the American National Standards Institute (ANSI) in 1986, and of the International Organization for Standardization (ISO) in 1987
SQL is a Standard - BUT....
Although SQL is an ANSI/ISO standard, there are different versions of the SQL language.
However, to be compliant with the ANSI standard, they all support at least the major commands (such as SELECT
, UPDATE
, DELETE
, INSERT
, WHERE
) in a similar manner.
These SQL commands are mainly categorized into five categories:
- DDL – Data Definition Language.
- DQL – Data Query Language.
- DML – Data Manipulation Language.
- DCL – Data Control Language.
- TCL – Transaction Control Language.
- DQL – Data Query Language
Data Definition Language
DDL is the short name for Data Definition Language, which deals with database schemas and descriptions, of how the data should reside in the database.
- CREATE: to create a database and its objects like (table, index, views, store procedure, function, and triggers)
- ALTER: alters the structure of the existing database
- DROP: delete objects from the database
- TRUNCATE: remove all records from a table, including all spaces allocated for the records are removed
- COMMENT: add comments to the data dictionary
- RENAME: rename an object
Data Manipulation Language
DML is the short name for Data Manipulation Language which deals with data manipulation and includes most common SQL statements such SELECT, INSERT, UPDATE, DELETE, etc., and it is used to store, modify, retrieve, delete and update data in a database.
- SELECT: retrieve data from a database
- INSERT: insert data into a table
- UPDATE: updates existing data within a table
- DELETE: Delete all records from a database table
- MERGE: UPSERT operation (insert or update)
Data Control Language
DCL is short for Data Control Language which acts as an access specifier to the database.(basically to grant and revoke permissions to users in the database
- GRANT: grant permissions to the user for running DML(SELECT, INSERT, DELETE,…) commands on the table
- REVOKE: revoke permissions to the user for running DML(SELECT, INSERT, DELETE,…) command on the specified table
Transactional Control Language
TCL is short for Transactional Control Language which acts as an manager for all types of transactional data and all transactions. Some of the command of TCL are
- Roll Back: Used to cancel or Undo changes made in the database
- Commit: It is used to apply or save changes in the database
- Save Point: It is used to save the data on the temporary basis in the database
Data Query Language (DQL)
- Data query language(DQL) is the subset of “Data Manipulation Language”. The most common command of DQL is 1the SELECT statement. SELECT statement helps us in retrieving the data from the table without changing anything or modifying the table. DQL is very important for retrieval of essential data from a database.
Some of The Most Important SQL Commands
SELECT
- extracts data from a database
UPDATE
- updates data in a database
DELETE
- deletes data from a database
INSERT INTO
- inserts new data into a database
CREATE DATABASE
- creates a new database
ALTER DATABASE
- modifies a database
CREATE TABLE
- creates a new table
ALTER TABLE
- modifies a table
DROP TABLE
- deletes a table
CREATE INDEX
- creates an index (search key)
DROP INDEX
- deletes an index
Using SQL in Your Web Site
To build a web site that shows data from a database, you will need:
- An RDBMS database program (i.e. MS Access, SQL Server, MySQL)
- To use a server-side scripting language, like PHP or ASP
- To use SQL to get the data you want
- To use HTML / CSS to style the page
Top comments (2)
Insightful 🙌🏻
thanks sir