Database Lab Session-3
Database Lab Session-3
COMMANDS OF SQL
If you omit the WHERE clause, all records in the table will be
updated!
INSERT
• By using truncate command data will be removed permanently & will not get
back.
• by using delete command data will be removed temporally & get back by
using roll back command.
• By using delete command data will be removed based on the condition.
• where as by using truncate command there is no condition.
• Truncate is a DDL command & delete is a DML command.
TO RETRIEVE DATA FROM ONE OR MORE
TABLES.
• SELECT FROM: To display all fields for all records.
• Syntax : SELECT * FROM relation_name;
• Example : select * from student;
• SELECT FROM: To display a set of fields for all records of relation.
• Syntax: SELECT a set of fields FROM relation_name;
• Example: select sno, sname from student;
SELECT - FROM -WHERE:
• This query is used to display a selected set of fields for a selected set of
records of a relation.
• Syntax: SELECT a set of fields FROM relation_name WHERE condition;
• Example: select * FROM student WHERE grade <=20;
SQL SELECT DISTINCT STATEMENT