SQL is a language to specify queries in a structured manner. Structured means relational data.
SQL is a language to specify queries in a relational database.
SQL (Structured Query Language) is a computer language for storing, manipulating, and retrieving data stored in relational databases.
SQL allows users to communicate with Relational Databases and retrieve data from their tables.
SQL is the standard language for RDBMS.
All Relational Database Management Systems (RDBMS) like "MySQL, MS Access, Oracle, Sybase, DB2, Informix, PostgreSQL Server" use SQL as the standard database language.
The data in RDBMS is stored in database objects called tables.
A table is a collection of related data entries and consists of columns and rows.
Dr. E.F. Codd published a paper on the Relational Model ("A Relational Model of Data for Large Shared Data Banks") in 1970 in ACM journal. Using the mathematical concepts of Relational Algebra and Tuple Relational Calculus, this model was accepted as the definitive model for RDBMS.
IBM implemented the SQL language, originally called SEQUEL (Structured English Query Language) as part of the System R project in the early 1970s.
SEQUEL was renamed/shortened to SQL (Structured Query Language).
SQL became a standard of the American National Standards Institute (ANSI) in 1986 and of the International Organization for Standardization (ISO) in 1987.
ANSI and ISO standard SQL has different versions: SQL-86, SQL-89, SQL-92, SQL:1999, SQL:2003, SQL:2006, SQL:2008, SQL:2011, SQL:2016.
Vendors of commercial systems (like Oracle, SQL Server, etc.) offer most of the major features, plus varying feature sets from later standards and special proprietary extensions.
SQL is a Domain-Specific Language.
SQL is a declarative language, i.e., a non-procedural language.
SQL allows us to declare what we want to do, but not how to do it.
In SQL, we can specify through queries what data we want but do not specify how to get that data.
In contrast, languages like C are procedural as they use functions, procedures, loops, etc., to specify what to do and how to do it.
The database/SQL engine is very powerful. When we write an SQL query, it first parses it; then it figures out its internal algorithms and tries to select an algorithm which will be the best for that particular query. It then applies that algorithm, finds the answer, and returns it.
⇒ SQL is based on Relational Algebra and Tuple Relational Calculus.
⇒ SQL can execute queries against a database
⇒ SQL can retrieve data from a database.
⇒ SQL can insert records into a database.
⇒ SQL can update records in a database.
⇒ SQL can delete records from a database.
⇒ SQL can create new databases.
⇒ SQL can create new tables in a database.
⇒ SQL can create stored procedures in a database.
⇒ SQL can create views in a database.
⇒ SQL can set permissions on tables, procedures, and views.
1.Data Definition Language (DDL)
2.Data Manipulation Language (DML)
3.Data Control Language (DCL)
4.Transaction Control Language (TCL)
Data Definition Language (DDL) commands are used to define the structure and schema of the database.
CREATE - to create a new table or database.
ALTER - to alter the structure of a table.
DROP - to delete a table from the database.
TRUNCATE - to delete all records from a table.
RENAME - to rename a table.
Data Manipulation Language (DML) commands are used for accessing and manipulating the data stored in the database.
SELECT - to retrieve data from the database.
INSERT - to insert a new row into a table.
UPDATE - to update an existing row in a table
DELETE - to delete a row from a table.
Data Control Language (DCL) commands are used to control the access to the data stored in the database.
GRANT - to grant permission to a user for database access.
REVOKE - to take back granted permission from a user.
Transaction Control Language (TCL) commands are used to manage the changes made by the DML statements.
COMMIT - to permanently save the transaction.
ROLLBACK - to undo a transaction.
SAVEPOINT - to temporarily save a transaction so that you can rollback to that point if necessary.
Note: TCL Commands are used only for DML commands while DDL and DCL commands are auto-committed.
SQL is NOT case-sensitive.
For example: select is the same as SELECT.
However, the names of databases, tables, and columns are case-sensitive.
For example: In the given SQL query, ACCOUNT is different from account.