在SQL语法中,如果您打算使用“在哪里”,“删除自”中的“来自”是否是可选的? [英] In SQL syntax, is 'from' in 'delete from' optional if you plan to use 'where'?
问题描述
我是SQL新手。我们有一些适用于SQL Server 2005/2008,Oracle 10和Sybase的代码。
I am new to SQL. We have some code that should work on SQL Server 2005/2008, Oracle 10 as well as Sybase.
我正在编写一个脚本,试图找出给定的表存储过程会修改(但不会删除),例如插入
,更新
和删除
。
I was writing a script to try to figure out which tables a given stored procedure modifies (but does not drop), e.g insert
, update
and delete
.
一个被删除的
令人费解-有时我会看到类似这样的语句:
The delete
one turned out being puzzling - sometimes I see statements like:
delete phone_book where ...
相对于:
delete from phone_book where ...
那么...在这种情况下, from
关键字是真的可选吗?这会引起任何问题吗?
So ... is the from
keyword truly optional in this case? Does this cause any problems? Is it just a bad style, or does it not matter?
我没有找到对 T-SQL
,这将使 from
是可选的。我想这将统一我上面提到的所有3个供应商。
I have not found a reference to T-SQL
that would make from
optional. I suppose that this is what would unify all 3 vendors I mentioned above.
欢迎问题/评论/链接(还是欢迎?)。
Questions/comments/links are welcomed (or is it welcome?).
推荐答案
在此位置 FROM
是可选的( SQL Server , Oracle , Sybase )。
At this place the FROM
is optional (SQL Server, Oracle, Sybase).
但是,两者之间存在细微的差异:例如,Oracle允许为表名分配别名,而SQL Server则不允许。
However, there are subtle differences: Oracle for instance allows assigning an alias to the table name, where SQL Server doesn't; and other things are also a little bit different.
还要注意,您的 FROM
示例与以下示例不同:它是强制性的:
Also note that your FROM
sample is differnet from the following where it is mandatory:
DELETE phone_book FROM some_table WHERE ...
这篇关于在SQL语法中,如果您打算使用“在哪里”,“删除自”中的“来自”是否是可选的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!