1.

Explain DML commands with example.

Answer»

The data manipulation commands are used for retrieval (view) of data, insertion of new data, modification of data or deletion. The DML commands include insert, delete and update.

1. INSERT command :
It is used to inserts new rows into the table.
Syntax:
INSERT INTO tablename (columnname1, columnname2,…) VALUES (value1, , value2, ..);
Example:
INSERT INTO student (Regno, name, Combn, fees) VALUES (1234, ‘Hemanth’, ‘PCMCs’,15000);

2. UPDATE command:
It can be used to change row values from a table. The SET keyword takes the column in which values need to be changed or updated. The WHERE keyword is used to filter the records in some conditions.
Syntax :
UPDATE tablename SET columnname = values WHERE Condition; Example: UPDATE student SET combn = ‘PCMCs’ where combn=’pcmc’;

3. DELETE Command :
It is used to delete/remove the tuples/rows from the table. All the rows will be deleted if WHERE clause is not used in the statement otherwise it selects the rows for delete which satisfies the condition.
Syntax:
DELETE from tablename WHERE Condition;
Example:
DELETE from student;
DELETE from student WHERE regno=1234;



Discussion

No Comment Found

Related InterviewSolutions