What is SQL?
SQL (pronounced as Sequel or some prefer es-que-el) stands for Structured Query Language. Let us focus on the three words that form the full form of SQL and see their definitions :
- Structured : construct or arrange according to a plan; give a pattern or organization to.
- Query : a question or a request for information about something.
- Language : here, the language stands for programming lanuage i.e. a way to communicate with a software.
According to Wikipedia : SQL is a special-purpose programming language designed for managing data held in a relational database management system (RDBMS).
Let’s rephrase it in simpler words for better understanding and look at the definitions about the technical terms that we encounter while doing it.
What is a Database?
A database is an organized collection of data. By “organized” we mean it is stored in such a manner that it can be efficiently utilized by the applications / processes as per their requirement. Utilization can mean extracting data or inserting or updating or deleting data, or it can be a combination of two or more activities. To perform operations on a database we require Database Management Systems (DBMS).
What are Database Management Systems?
Database management systems (DBMSs) are specially designed software applications that interact with the user, other applications, and the database itself to capture and analyze data. A general-purpose DBMS is a software system designed to allow the definition, creation, querying, update, and administration of databases. (Source : Wikipedia)
SQL – ANSI and ISO Standard
ANSI stands for American National Standards Institute and ISO stands for Internation Organization for Standardization. SQL became an ANSI standard in 1986 and ISO standard in 1987. To understand what “standard” means, let’s look at the definition of “Technical Standard”.
What is Technical Standard?
A technical standard is an established norm or requirement in regard to technical systems. It is usually a formal document that establishes uniform engineering or technical criteria, methods, processes and practices.
What is SQL used for?
Now that we are aware about all the related terminlogies and have a fair idea about what SQL is, let us take a look at what we can actually do with SQL.
SQL consists of two types of languages, namely, data definition language (DDL) and data manipulation language (DML).
As we already know that SQL is used to manage data held in RDBMS, let us get a generalized idea about what things are present in RDBMS. We shall refer to Oracle Databases in this example. Oracle database consists of Users. Each user has a schema associated to itself. A schema comprises a collection of schema objects. Examples of schema objects include:
- Table : an organized set of data elements (values) using a model of vertical columns (which are identified by their name) and horizontal rows, the cell being the unit where a row and column intersect.
- View : the result set of a stored query on the data.
- Sequence : an ordered list.
- Synonym : an alias or alternate name for a table, view, sequence, or other schema object.
- Index : a data structure that improves the speed of data retrieval operations on a database table at the cost of additional writes and the use of more storage space to maintain the extra copy of data.
There are few other schema objects such as clusters, procedures, functions, packages etc. But let us not get ahead of ourselves at this point. We shall discuss them later once we get comfortable with the basics.
So getting back to DDL and DML.
What is Data Definition Language?
A data definition language or data description language (DDL) is a syntax similar to a computer programming language for defining data structures, especially database schemas. We shall see the syntax and examples of DDL once we finish with understanding the concepts.
What is Data Manipulation Language?
A data manipulation language (DML) is a family of syntax elements similar to a computer programming language used for inserting, deleting and updating data in a database.
Let us now proceed with practical examples of SQL > Select, Insert, Update and Delete SQL examples