To modify existing rows of the table _______ statement is used.a)ALTE...
- SQL UPDATE is the command used to update existing table rows with new data values.
- SQL ALTER table command is used to modify the definition (structure) of a table by modifying the definition of its column.
- The SQL COMMIT command is the transactional command used to save changes invoked by a transaction to the database.
- The SQL DELETE command is used to delete rows from a table.
Option 2 is invalid. There is no such MODIFY command in SQL.
View all questions of this test
To modify existing rows of the table _______ statement is used.a)ALTE...
Explanation:
To modify existing rows of a table, the UPDATE statement is used in SQL.
UPDATE Statement:
The UPDATE statement in SQL is used to modify the existing records in a table. It allows you to change the values of one or more columns in a table based on specified conditions.
Syntax:
The basic syntax for the UPDATE statement is as follows:
```
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
```
- table_name: specifies the name of the table where the records are to be updated.
- column1, column2, ...: specifies the columns to be updated.
- value1, value2, ...: specifies the new values to be assigned to the columns.
- WHERE: specifies the conditions that must be met for the update to be applied. If the WHERE clause is omitted, all rows in the table will be updated.
Example:
Let's say we have a table named "employees" with the following structure:
```
+----+----------+-----------+
| ID | Name | Salary |
+----+----------+-----------+
| 1 | John | 5000 |
| 2 | Mary | 6000 |
| 3 | Steven | 4500 |
+----+----------+-----------+
```
Now, if we want to update the salary of employee with ID 2 to 7000, we can use the following UPDATE statement:
```
UPDATE employees
SET Salary = 7000
WHERE ID = 2;
```
After executing the above statement, the table will be modified as follows:
```
+----+----------+-----------+
| ID | Name | Salary |
+----+----------+-----------+
| 1 | John | 5000 |
| 2 | Mary | 7000 |
| 3 | Steven | 4500 |
+----+----------+-----------+
```
In this example, the UPDATE statement is used to modify the salary column of the employees table for the row with ID 2. The SET clause specifies the new value for the Salary column, and the WHERE clause specifies the condition that must be met (ID = 2) for the update to be applied.
Therefore, the correct option is c) UPDATE as it is used to modify existing rows of a table in SQL.
To make sure you are not studying endlessly, EduRev has designed Railways study material, with Structured Courses, Videos, & Test Series. Plus get personalized analysis, doubt solving and improvement plans to achieve a great score in Railways.