Hey guys, I'm Venket and in this video we'll understand the difference between SQL, T-SQL and
PL/SQL. As many of us already know, SQL stands for Structured Query Language. So, SQL is a language,
specifically it's a language for relational databases. Now, what is a relational database
and why do we use it? Well, in simple terms, a relational database is a collection of tables
to store data. The tables are usually related to each other by primary and foreign key constraints,
hence the term relational database management system, in short RDBMS. For example, let's say,
we want to store our organization employees data, we create a database, maybe EmployeesDB
or we can give it any meaningful name we want and then in this database, we create three tables,
maybe for example, Departments, to store the list of all departments, Gender, to store different
genders, Male and Female for example and finally, Employees, to store the list of all employees.
Now, I have some basic SQL statements here. These two statements at the top, creates a database
with name EmployeesDB and puts it to use. So, let's execute these two statements. There we go,
our database EmployeesDB is created and ready to use, it's also selected in this drop-down list.
Now, within this EmployeesDB database, we want to create these three tables - Departments, Gender
and Employees. Notice, within the Departments table, this "Id" column is the primary key column.
Even in Gender table, "Id" is the primary key and same idea even within the Employees table, "Id" is
primary key column and this Employees table is related to both these two tables - Departments
and Gender. Notice, the DeptId column within the Employees table, it's a foreign key referencing
Id column from the Departments table. Same idea with GenderId, it's also a foreign key
referencing Id column from the Gender table. So, let's create these three tables
Commands completed. Now, let's insert some test data
into these three tables and we have the respective insert queries right here,
so let's select all these insert queries and execute them. Again, data is inserted now,
let's select that data again. We have the select SQL statements right here. Let's execute them.
There we go, we have all our departments, genders and employees. Now, let's say as an end user,
I want a report that looks like this. In the report, I want the list of all employee names
along with their department names and gender names. Now, if we take a look at the data that we
have in the Employees table, within the Employees table notice we don't have department name
and gender name, instead we have the ids and these ids does not make any sense to the end user. Now,
to be able to get the department name, we have to join this Employees table with the Departments
table. Similarly, to get the gender name we have to again join this Employees table with the Gender
table. So, basically we have that join query right here, we are joining Employees table with
Departments and Gender to retrieve the department name and gender name. Let's execute this query.
There we go, we have the data as expected. So, to create the database itself, tables, relationships
and to insert, update, delete and even select data, we use SQL - Structured Query Language. So,
in simple terms SQL is a database language, we use it on a database to create database objects
like tables, views, functions etc. We also use it to insert, update, delete and select data. So,
in short SQL is a database language, then what is T-SQL and PL/SQL and how is it different from
SQL? Well, you can think of SQL as a standard database language. It was initially developed by
IBM and later ANSI, that is, American National Standards Institute made it a standard. So SQL
is an ANSI standard and based on it different database vendors like Microsoft, Oracle and many
other organizations developed their own database query language. Standards are always good because
they allow us to write similar queries across different relational database management systems.
Different vendors like Microsoft and Oracle for example support most of the features of the ANSI
SQL standard. However, these database vendors also include their own non-standard features
that extend the standard SQL language. So, the database that is developed by Microsoft
is called Microsoft SQL Server or MS SQL Server for short. The language that Microsoft developed
to query SQL Server database is called Transact SQL or T-SQL for short. Similarly,
Oracle corporation developed a database management system called Oracle and the language that we use
to query Oracle database is PL/SQL, by the way PL stands for Procedural Language. So, you can
think of SQL as a subset of T-SQL and PL/SQL. A word of caution here, both T-SQL and PL/SQL
does not implement 100% of the feature set of standard SQL, but majority of the standard
features are implemented, you can see that from the diagram here. Although not entirely true,
you can still think, SQL is almost a subset of T-SQL and PL/SQL. This means, if you know T-SQL
or PL/SQL, then you already know the standard SQL. So, the point is, the standard SQL is
same across all database vendors, this means if you know the standard SQL, then you know how to do
most of the basic things on most of the database management systems like SQL Server, Oracle, MySQL,
PostgreSQL etc. If you're wondering, what is MySQL and PostgreSQL? Well, just like
SQL Server and Oracle, they are also relational database management systems. Here is the summary.
SQL is the standard database language. Based on this standard SQL database vendors like
Microsoft, Oracle and many other organizations developed their own database query languages.
T-SQL is a proprietary procedural language for working with Microsoft SQL Server database.
Similarly PL/SQL is a proprietary procedural language for working with Oracle database. T-SQL
and PL/SQL are an extension to standard SQL, this means they have more features and functions
than the standard SQL. For example, features such as local variables are added. Similarly
many many built-in functions are added for processing strings, numbers, dates and other types
of data. They also added the capability to write stored procedures. So, in short these procedural
languages like T-SQL and PL/SQL for example help us in writing queries easier, quicker and more
efficiently. If you want to learn SQL and Transact SQL, please check out this SQL Server tutorial for
beginners course. We've covered everything you need, from the basics to advanced SQL
concepts. I hope you'll find this course useful. That's it in this video. Thank you for listening.