PL/SQL 和 T-SQL 有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5428662/
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 PL/SQL and T-SQL?
提问by Abe Miessler
All that I know is that the former is Oracle and the latter is SQL Server. I assume some things might be easierin one versus the other but are there certain things I can do in PL that I can't in T?
我只知道前者是 Oracle,后者是 SQL Server。我认为有些事情在一个和另一个中可能更容易,但是有哪些我可以在 PL 中做而在 T 中不能做的事情?
Are there fundamental differences that I should be aware of? If so, what are they?
是否存在我应该注意的根本差异?如果有,它们是什么?
采纳答案by devio
T-SQL and PL/SQL are two completely different programming languages with different syntax, type system, variable declarations, built-in functions and procedures, and programming capabilities.
T-SQL 和 PL/SQL 是两种完全不同的编程语言,具有不同的语法、类型系统、变量声明、内置函数和过程以及编程能力。
The only thing they have in common is direct embedding of SQL statements, and storage and execution inside a database.
它们唯一的共同点是直接嵌入 SQL 语句,以及在数据库中存储和执行。
(In Oracle Forms, PL/SQL is even used for client-side code, though integration with database-stored PL/SQL is (almost) seemless)
(在 Oracle Forms 中,PL/SQL 甚至用于客户端代码,尽管与数据库存储的 PL/SQL 集成(几乎)是无缝的)
回答by Digitz
The only fundamental difference is that PL/SQL is a procedural programming language with embedded SQL, and T-SQL is a set of procedural extensions for SQL used by MS SQL Server. The syntax differences are major. Here are a couple good articles on converting between the two:
唯一的根本区别是 PL/SQL 是一种带有嵌入式 SQL 的过程编程语言,而 T-SQL 是 MS SQL Server 使用的 SQL 过程扩展集。语法差异是主要的。这里有几篇关于在两者之间转换的好文章:
回答by Kuberchaun
One tid bit I can add is take what you know in one and while using the other forget what you know(except for using set based logic when ever possible).
我可以补充的一点是,在一个中获取您所知道的,而在使用另一个时忘记您所知道的(除了尽可能使用基于集合的逻辑)。
One example of the differences is cursor's are typically considered a less ideal solution in T-SQL unless there is a really good reason to use them which there is often not. In Oracle the cursor's are much more optimized for example they have bulk abilities, that is the ability to work on a set of data much like a normal SQL statement can. So in Oracle using a cursor isn't an instant failed code review where it might in a TSQL code review.
差异的一个例子是游标通常被认为是 T-SQL 中不太理想的解决方案,除非有很好的理由使用它们,而通常没有。在 Oracle 中,游标的优化程度更高,例如它们具有批量功能,即像普通 SQL 语句一样处理一组数据的能力。因此,在 Oracle 中使用游标并不是在 TSQL 代码中可能会立即失败的代码。
Overall T-SQL is much easier to learn as there's not much to it as far as languages are concerned. PL/SQL is a richer language, and therefore more complicated. It is not a hard language to pick up if have a good book. Overall I really like PLSQL for it's depth and I really like TSQL for it's simplicity.
总体而言,T-SQL 更容易学习,因为就语言而言,它没有太多内容。PL/SQL 是一种更丰富的语言,因此也更复杂。如果有一本好书,这不是一种很难掌握的语言。总的来说,我真的很喜欢 PLSQL,因为它的深度,我真的很喜欢 TSQL,因为它很简单。
回答by SqlRyan
They're not necessarily easier, just different - ANSI-SQL is the standard code that's shared between them - the SELECT, WHERE and other query syntax, and T-SQL or PL/SQL is the control flow and advanced coding that's added on top by the database vendor to let you write stored procedures and string queries together.
它们不一定更简单,只是不同 - ANSI-SQL 是它们之间共享的标准代码 - SELECT、WHERE 和其他查询语法,而 T-SQL 或 PL/SQL 是控制流和添加在顶部的高级编码由数据库供应商允许您将存储过程和字符串查询一起编写。
It's possible to run multiple queries using just ANSI-SQL statements, but if you want to do any IF statements or handle any errors, you're using more than what's in the ANSI spec, so it's either T-SQL or PL/SQL (or whatever the vendor calls it if you're not using Microsoft or Oracle).
可以仅使用 ANSI-SQL 语句运行多个查询,但是如果您想执行任何 IF 语句或处理任何错误,您使用的比 ANSI 规范中的更多,因此它是 T-SQL 或 PL/SQL(如果您不使用 Microsoft 或 Oracle,则无论供应商如何称呼它)。
回答by MichaB
PL/SQL and T-SQL are extensions for SQL. PL/SQL is used for Oracle databases and T-SQL is used for Microsoft databases.
PL/SQL 和 T-SQL 是 SQL 的扩展。PL/SQL 用于 Oracle 数据库,T-SQL 用于 Microsoft 数据库。
Here are more useful informations: http://techdifferences.com/difference-between-t-sql-and-pl-sql.html
这里有更多有用的信息:http: //techdifferences.com/difference-between-t-sql-and-pl-sql.html