Informatics Practices
Kabir has created the following table named exam :
| RegNo | Name | Subject | Marks |
|---|---|---|---|
| 1 | Sanya | Computer Science | 198 |
| 2 | Sanchay | IP | 100 |
| 3 | Vinesh | CS | 90 |
| 4 | Sneha | IP | 99 |
| 5 | Akshita | IP | 100 |
Help him in writing SQL queries to perform the following tasks :
(i) Insert a new record in the table having following values : [6, 'Khushi', 'CS', 85]
(ii) To change the value "IP" to "Informatics Practices" in Subject column.
(iii) To remove the records of those students whose marks are less than 30.
(iv) To add a new column Grade of suitable datatype.
(v) To display records of "Informatics Practices" subject.
Answer
(i)
INSERT INTO exam(RegNo, Name, Subject, Marks)
VALUES(6, 'Khushi', 'CS', 85);
(ii)
UPDATE exam
SET Subject = 'Informatics Practices'
WHERE Subject = 'IP';
(iii)
DELETE FROM EXAM
WHERE MARKS < 30 ;
(iv)
ALTER TABLE EXAM
ADD COLUMN (Grade VARCHAR(1));
(v)
SELECT * FROM EXAM
WHERE Subject = "Informatics Practices";
Related Questions
How are SQL commands classified ?
Differentiate between DDL and DML commands.
What is the use of UPDATE statement in SQL ? How is it different from ALTER statement ?
Mr. Shankar created a table VEHICLE with 3 rows and 4 columns. He added 1 more row to it and deleted one column. What is the Cardinality and Degree of the Table VEHICLE ?