Search code examples
sqlt-sqlplsql

What is the difference between SQL, PL-SQL and T-SQL?


What is the difference between SQL, PL-SQL and T-SQL?

Can anyone explain what the differences between these three are, and provide scenarios where each would be relevantly used?


Solution

  • SQL is a declarative language to operate on relational data: tables, views, resultsets and similar.

    It's more or less standardized, and used by almost all relational database management systems: SQL Server, Oracle, MySQL, PostgreSQL, DB2, Informix, etc.

    Most database engines also support procedural languages (as opposed to declarative that SQL is). They have variables, loops, conditional operators and explicitly controlled execution flow, something that SQL lacks. Usually they are designed to closely integrate with SQL.

    They are, for the most part, used to write stored procedures: pieces of code that live on the server and implement complex business rules that are hard or impossible to implement with pure set-based operations.

    • PL/SQL is a proprietary procedural language used by Oracle

    • PL/pgSQL is a procedural language used by PostgreSQL

    • TSQL is a proprietary procedural language used by Microsoft in SQL Server.