DBMS Exercise 1
DBMS Exercise 1
Practice Exercise
Note: Students should append last 4 digit of their register number with table name
given.
For example student with register number 111717104001 should create table as
Data Manipulation Languages have their functional capability organized by the initial
word in a statement, which is almost always a verb. In the case of SQL, these verbs are:
SELECT
An SQL SELECT statement returns a result set of records from one or more tables. It
retrieves zero or more rows from one or more base tables or views in a database. In
most applications, SELECT is the most commonly used Data Manipulation Language
(DML) command.
Example:
Example:
Example:
INSERT
The number of columns and values must be the same. The values specified (or
implied) by the INSERT statement must satisfy all the applicable constraints (such as
primary keys, CHECK constraints, and NOT NULL constraints). If a syntax error occurs or if
any constraints are violated, the new row is not added to the table and an error returned
instead.
Syntax:
INSERT INTO table (column1, [column2, ... ]) VALUES (value1, [value2, ...])
Example:
INSERT INTO
student(name,registerno,branchno,section,joindate,mark,email
id) VALUES ('Aarthi',11306205001,1,'A','01-apr-2006',99,
'[email protected]')
Note that there are six values specified for the record. These correspond to the
table attributes in the order they were defined: name, registerno, branchno, section,
joindate, mark
UPDATE
A SQL UPDATE statement that changes the data of one or more records in a table.
Either all the rows can be updated, or a subset may be chosen using a condition.
Syntax:
For the UPDATE to be successful, the user must have data manipulation privileges (UPDATE
privilege) on the table or column, the updated value must not conflict with all the applicable
constraints (such as primary keys, unique indexes, CHECK constraints, and NOT NULL
constraints).
Example:
UPDATE student
SET mark = mark + 2
WHERE registerno = 11306205001;
DELETE
An SQL DELETE statement removes one or more records from a table. A subset may be
defined for deletion using a condition, otherwise all records are removed.
Syntax:
Any rows that match the WHERE condition will be removed from the table. If the WHERE clause
is omitted, all rows in the table are removed. The DELETE statement should thus be used with
caution!
The DELETE statement does not return any rows; that is, it will not generate a result set.
Example :
DELETE FROM student
WHERE registerno = 11306205001;
Practice Exercise
9. Display the detail of grade for the mark between 81 and 90.
14. Display the Maximum mark of branch where Maximum Mark greater than 90.
15. Display the Name, Register Number, E-Mail ID and Join Date of Students who have
Result
Thus to write SQL using Data Definition Commands, Data Manipulation Commands
for inserting, deleting, updating and retrieving Tables and Transaction Control