Informatics Practices
What is the use of UPDATE statement in SQL ? How is it different from ALTER statement ?
Answer
The UPDATE statement is used to modify existing records in a table. It specifies the rows to be changed using the WHERE clause, and sets the new data using the SET keyword. In contrast, the ALTER statement is used to modify the structure of a table, such as adding, modifying, or deleting columns, and adding or dropping constraints.
Related Questions
Differentiate between DDL and DML commands.
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.
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 ?
Consider the following table named "GYM" with details about fitness items being sold in the store. Write command of SQL for (i) to (iv).
Table : GYM
ICODE INAME PRICE BRANDNAME G101 Power Fit Exerciser 20000 Power Gymea G102 Aquafit Hand Grip 1800 Reliable G103 Cycle Bike 14000 Ecobike G104 Protoner Extreme Gym 30000 Coscore G105 Message Belt 5000 Message Expert G106 Cross Trainer 13000 GTC Fitness (i) To display the names of all the items whose name starts with "A".
(ii) To display ICODEs and INAMEs of all items, whose Brandname is Reliable or Coscore.
(iii) To change the Brandname to "Fit Trend India" of the item, whose ICODE as "G101".
(iv) Add a new row for new item in GYM with the details :
"G107", "Vibro exerciser", 21000, "GTCFitness"