SQL、PL-SQL 和 T-SQL 之间有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1043265/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the difference between SQL, PL-SQL and T-SQL?
提问by Goober
What is the difference between SQL, PL-SQL and T-SQL?
SQL、PL-SQL 和 T-SQL 之间有什么区别?
Can anyone explain what the differences between these three are, and provide scenarios where each would be relevantly used?
任何人都可以解释这三者之间的区别,并提供每一种都可以相关使用的场景吗?
回答by Quassnoi
SQL
is a query language to operate on sets.It is more or less standardized, and used by almost all relational database management systems: SQL Server, Oracle, MySQL, PostgreSQL, DB2, Informix, etc.
PL/SQL
is a proprietary procedural language used by OraclePL/pgSQL
is a procedural language used by PostgreSQLTSQL
is a proprietary procedural language used by Microsoft in SQL Server.
SQL
是一种对集合进行操作的查询语言。它或多或少是标准化的,几乎被所有关系数据库管理系统使用:SQL Server、Oracle、MySQL、PostgreSQL、DB2、Informix 等。
PL/SQL
是 Oracle 使用的专有过程语言PL/pgSQL
是 PostgreSQL 使用的过程语言TSQL
是 Microsoft 在 SQL Server 中使用的专有过程语言。
Procedural languages are designed to extend SQL's abilities while being able to integrate well with SQL. Several features such as local variables and string/data processing are added. These features make the language Turing-complete.
过程语言旨在扩展 SQL 的能力,同时能够与 SQL 很好地集成。添加了一些功能,例如局部变量和字符串/数据处理。这些特性使语言图灵完备。
They are also used to write stored procedures: pieces of code residing on the server to manage complex business rules that are hard or impossible to manage with pure set-based operations.
它们还用于编写存储过程:驻留在服务器上的代码片段,用于管理复杂的业务规则,这些规则很难或不可能通过纯基于集合的操作进行管理。
回答by Arunprasanth K V
SQL
SQL
SQL is used to communicate with a database, it is the standard language for relational database management systems.
SQL 用于与数据库进行通信,它是关系数据库管理系统的标准语言。
In detail Structured Query Languageis a special-purpose programming language designed for managing data held in a relational database management system (RDBMS), or for stream processing in a relational data stream management system (RDSMS).
详细而言,结构化查询语言是一种专用编程语言,旨在管理关系数据库管理系统 (RDBMS) 中保存的数据,或用于关系数据流管理系统 (RDSMS) 中的流处理。
Originally based upon relational algebra and tuple relational calculus, SQL consists of a data definition language and a data manipulation language. The scope of SQL includes data insert, query, update and delete, schema creation and modification, and data access control. Although SQL is often described as, and to a great extent is, a declarative language (4GL), it also includes procedural elements.
SQL 最初基于关系代数和元组关系演算,由数据定义语言和数据操作语言组成。SQL 的范围包括数据插入、查询、更新和删除、模式创建和修改以及数据访问控制。尽管 SQL 通常被描述为并且在很大程度上是一种声明性语言 (4GL),但它也包含过程元素。
PL/SQL
PL/SQL
PL/SQL is a combination of SQL along with the procedural features of programming languages.It was developed by Oracle Corporation
PL/SQL 是 SQL 与编程语言的过程特性的结合。它是由甲骨文公司开发的
Specialities of PL/SQL
PL/SQL 的特长
- completely portable, high-performance transaction-processing language.
- provides a built-in interpreted and OS independent programming environment.
- directly be called from the command-line SQL*Plus interface.
- Direct call can also be made from external programming language calls to database.
- general syntax is based on that of ADA and Pascal programming language.
- Apart from Oracle, it is available in TimesTen in-memory database and IBM DB2.
- 完全可移植的高性能事务处理语言。
- 提供了一个内置的解释和操作系统独立的编程环境。
- 直接从命令行 SQL*Plus 界面调用。
- 也可以从外部编程语言对数据库的直接调用。
- 通用语法基于 ADA 和 Pascal 编程语言的语法。
- 除了 Oracle 之外,它还在 TimesTen 内存数据库和 IBM DB2 中可用。
T-SQL
查询语句
Short for Transaction-SQL, an extended form of SQL that adds declared variables, transaction control, error and exceptionhandling and row processing to SQL
Transaction-SQL 的缩写,一种SQL的扩展形式,它将声明的变量、事务控制、错误和异常处理以及行处理添加到 SQL
The Structured Query Language or SQL is a programming language that focuses on managing relational databases. SQL has its own limitationswhich spurred the software giant Microsoft to build on top of SQL with their own extensions to enhance the functionality of SQL. Microsoft added code to SQL and called it Transact-SQL or T-SQL. Keep in mind that T-SQL is proprietary and is under the control of Microsoft while SQL, although developed by IBM, is already an open format.
结构化查询语言或 SQL 是一种专注于管理关系数据库的编程语言。SQL 有其自身的局限性,这促使软件巨头Microsoft 在 SQL 之上构建自己的扩展,以增强 SQL 的功能。微软向 SQL 添加了代码,并将其称为 Transact-SQL 或 T-SQL。请记住,T-SQL 是专有的并且受 Microsoft 控制,而 SQL 尽管由 IBM 开发,但已经是一种开放格式。
T-SQL adds a number of features that are not available in SQL.
T-SQL 添加了许多 SQL 中没有的功能。
This includes procedural programming elements and a local variable to provide more flexible control of how the application flows. A number of functions were also added to T-SQL to make it more powerful; functions for mathematical operations, string operations, date and time processing, and the like. These additions make T-SQL comply with the Turing completeness test, a test that determines the universality of a computing language. SQL is not Turing complete and is very limited in the scope of what it can do.
这包括过程编程元素和一个局部变量,以提供对应用程序如何流动的更灵活的控制。T-SQL 中还添加了许多功能,使其功能更加强大;用于数学运算、字符串运算、日期和时间处理等的函数。这些添加使 T-SQL 符合图灵完备性测试,该测试决定了计算语言的通用性。SQL 不是图灵完备的,并且它可以做的范围非常有限。
Another significant difference between T-SQL and SQL is the changes done to the DELETE and UPDATE commands that are already available in SQL. With T-SQL, the DELETE and UPDATE commands both allow the inclusion of a FROM clause which allows the use of JOINs. This simplifies the filtering of records to easily pick out the entries that match a certain criteria unlike with SQL where it can be a bit more complicated.
T-SQL 和 SQL 之间的另一个显着区别是对 SQL 中已经可用的 DELETE 和 UPDATE 命令所做的更改。对于 T-SQL,DELETE 和 UPDATE 命令都允许包含允许使用 JOIN 的 FROM 子句。这简化了对记录的过滤,以便轻松挑选出符合特定条件的条目,这与 SQL 不同,SQL 可能会更复杂一些。
Choosing between T-SQL and SQL is all up to the user.Still, using T-SQL is still better when you are dealing with Microsoft SQL Server installations. This is because T-SQL is also from Microsoft, and using the two together maximizes compatibility. SQL is preferred by people who have multiple backends.
在 T-SQL 和 SQL 之间进行选择完全取决于用户。尽管如此,当您处理 Microsoft SQL Server 安装时,使用 T-SQL 仍然更好。这是因为 T-SQL 也是来自 Microsoft,将两者结合使用可以最大限度地提高兼容性。SQL 是拥有多个后端的人的首选。
References, Wikipedea , Tutorial Points :www.differencebetween.com
参考资料,维基百科,教程要点:www.differencebetween.com
回答by diederikh
SQL
a language for talking to the database. It lets you select data, mutate and create database objects (like tables, views, etc.), change database settings.PL-SQL
a procedural programming language (with embedded SQL)T-SQL
(procedural) extensions for SQL used by SQL Server
SQL
一种与数据库对话的语言。它允许您选择数据、变异和创建数据库对象(如表、视图等),更改数据库设置。PL-SQL
一种过程编程语言(带有嵌入式 SQL)T-SQL
SQL Server 使用的 SQL 的(过程)扩展
回答by Manoj Pandey
1. SQLor Structured Query Language was developed by IBM for their product "System R".
1. SQL或结构化查询语言是由 IBM 为其产品“System R”开发的。
Later ANSImade it as a Standardon which all Query Languages are based upon and have extended this to create their own DataBase Query Language suits. The first standard was SQL-86and latest being SQL:2011
后来ANSI将其作为所有查询语言所基于的标准,并对其进行了扩展以创建自己的数据库查询语言套件。第一个标准是SQL-86,最新的是SQL:2011
2. T-SQLor Transact-SQL was developed by Sybaseand later co-owned by MicrosoftSQL Server.
2. T-SQL或 Transact-SQL 由Sybase开发,后来由MicrosoftSQL Server共同拥有。
3. PL/SQLor Procedural Language/SQL was OracleDatabase, known as "Relation Software" that time.
3. PL/SQL或Procedural Language/SQL是OracleDatabase,当时被称为“关系软件”。
I've documented this in my blog post.
我已经在我的博客文章中记录了这一点。
回答by Jayron Soares
Structured Query Language - SQL: is an ANSI-standard used by almost all SGBD's vendors around the world. Basically, SQL is a language used to define and manipulate data [DDL and DML].
结构化查询语言 - SQL:是全球几乎所有 SGBD 供应商都使用的 ANSI 标准。基本上,SQL 是一种用于定义和操作数据 [DDL 和 DML] 的语言。
PL/SQL is a language created by Oracle universe. PL/SQL combine programming procedural instructions and allows the creation of programs that operates directly on database scenario.
PL/SQL 是 Oracle Universe 创建的一种语言。PL/SQL 结合了编程过程指令,并允许创建直接在数据库场景上运行的程序。
T-SQL is Microsoft product align SQL patterns, with some peculiarities. So, feel free to test your limits.
T-SQL 是 Microsoft 产品对齐 SQL 模式,具有一些特殊性。因此,请随时测试您的极限。
回答by Kenta
SQL is a standard and there are many database vendors like Microsoft,Oracle who implements this standard using their own proprietary language.
SQL 是一个标准,并且有许多数据库供应商,如 Microsoft、Oracle,他们使用自己的专有语言实现了这个标准。
Microsoft uses T-SQL to implement SQL standard to interact with data whereas oracle uses PL/SQL.
Microsoft 使用 T-SQL 来实现 SQL 标准来与数据交互,而 oracle 使用 PL/SQL。