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 ...
as opposed to:
delete from phone_book where ...
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?
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?).
At this place the
FROM
is optional (SQL Server, Oracle, Sybase).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.
Also note that your
FROM
sample is differnet from the following where it is mandatory:From the Microsoft SQL Server documentation, FROM is optional.
Short Answer: Luceros answer is correct: it is optional
I have to maintain sql and adapt it between sql-server and Oracle. Here are some rules:
ORACLE Select statements need a from clause you can use from DUAL