These statement consist of queries that retrieve data from tables in database and statements that change the data in the database
Statement under this category are:
SELECT
INSERT
UPDATE
DELETE
LOCK TABLE etc.
Insert command
It is used to add rows to a table.
INSERT INTO TABLE-NAME VALUES (data value 1,data value 2);
The number and sequence of data values should match that of column in the table. If number of data values less, then specify the column names into which data is being entered as illustrated.
INSERT INTO TABLE-NAME(column 1, column 3)
To insert null values, NULL may be used
INSERT INTO EMP VALUES(1001,'sharma',NULL.NULL3000,NULL)
Queries
Query has following two components:
1.SELECT clause.
It lists name of columns containing the required data specifies the table in which these columns are located.
2.FROM clause.
It can also specify operations to be performed on the data and displays the result of these operations. Results of the query is displayed in a table form and is sometimes called result table. The rows in the result represent the data that meet the conditions; if no data qualifies, zero rows are selected.
Narrowing the query : WHERE clause
It narrow scope of the query by focusing on selected rows.
e.g.
SELECT NAME,TRAINER
FROM GUEST-ROSTER
WHERE TRAINER="TODD";
NAME TRAINER
SEAN PENCIL TODD
DON JACKSON TODD
DIANCA JOGGER TODD
Relational predicates: TRAINER ="TODD"
'=' is a simple relational operator.
There are nine simple relational operators:
= is equal to
!= is not equal to
<> is not equal to
> is greater than
!> is not greater than
< is less than
!< is not less than
>= is greater than or equal to
<= is less than or equal to
Other relational predicates
These are four other relational operators that can be used to form relational predicates:
BETWEEN...AND
IS NULL
IN
EXIST
1 Comment(s)