October 22, 2012

"TABLE" keyword and SQL statements

We are many a times confused about whether TABLE keyword appears in a SQL statement. Here I present a handy trick. It says:

Read below sentences in sequence-
Beside others, there are two types of SQL statements- DDL and DML.
DDL deals with creating, altering and dropping data structures such as tables.
DML deals with inseting, updating and deleting data within tables.

As DDL deals with main furniture of database, i.e., tables (similar to wooden tables) and they can drop your tables (on the ground to destroy them), they expect use of TABLE word explicitly.
e.g.,
CREATE TABLE t1(...);
ALTER TABLE t1 ...;
DROP TABLE t1;

As DML deals with data within tables, they do not use the word TABLE. In DML statements, table name appears directly (without use of keyword TABLE).
e.g.,
INSERT INTO table01 ...; -- TABLE keyword not used here
UPDATE table01 ...; -- TABLE keyword not used here
DELETE FROM table01 ...; -- TABLE keyword not used here

The above find is my own. In the beginning, even I had also been confused with the use of TABLE keyword. But, as it is rightly said, "Need is the mother of Discovery," I have finally come out of this trauma.


[If you like posts, do share their links.]

No comments:

Post a Comment

Add your say here: