208k views
0 votes
Using the emp_2 table, write a single SQL command to change the emp_pct value to 5.00 for the people with employee numbers 101, 105, and 107. a) UPDATE emp_2 SET emp_pct = 5.00 WHERE emp_number IN (101, 105, 107); b) ALTER TABLE emp_2 MODIFY emp_pct NUMBER(4, 2) DEFAULT 5.00 WHERE emp_number IN (101, 105, 107); c) INSERT INTO emp_2 (emp_number, emp_pct) VALUES (101, 5.00), (105, 5.00), (107, 5.00); d) DELETE FROM emp_2 WHERE emp_number IN (101, 105, 107) AND emp_pct = 5.00;

User Kalec
by
8.5k points

2 Answers

4 votes

Final answer:

The correct SQL command to update the emp_pct value to 5.00 for employee numbers 101, 105, and 107 in the emp_2 table is the UPDATE command with the specific WHERE clause.

Step-by-step explanation:

To update the emp_pct value to 5.00 for specific employee numbers in the emp_2 table using SQL, the correct command would be:

UPDATE emp_2 SET emp_pct = 5.00 WHERE emp_number IN (101, 105, 107);

This SQL statement uses the UPDATE command to modify existing records. The WHERE clause specifies which records should be updated—those with emp_number 101, 105, or 107. No other commands such as ALTER TABLE, INSERT INTO, or DELETE FROM would be appropriate for this action since those commands are used for different purposes in SQL.

User Joseph Tinoco
by
8.5k points
2 votes

Final answer:

The correct SQL command is: `UPDATE emp_2 SET emp_pct = 5.00 WHERE emp_number IN (101, 105, 107);`. This command modifies the emp_pct value to 5.00 for employees with employee numbers 101, 105, and 107 in the emp_2 table.

Step-by-step explanation:

The correct SQL command to modify the `emp_pct` value to 5.00 for employees with employee numbers 101, 105, and 107 from the `emp_2` table is the 'a' option - `UPDATE emp_2 SET emp_pct = 5.00 WHERE emp_number IN (101, 105, 107);`. This SQL statement uses the `UPDATE` command to modify the `emp_pct` column specifically for the employee numbers 101, 105, and 107 that match the condition specified in the `WHERE` clause.

The `UPDATE` command in SQL is used to modify existing records in a table. In this case, it changes the value of the `emp_pct` column to 5.00 for the specified employee numbers by utilizing the `WHERE` clause, which filters the records based on the condition specified (emp_number IN (101, 105, 107)).

Options b, c, and d are incorrect for the given task:

- Option b attempts to alter the table structure and set the default value for `emp_pct`, but it doesn't update specific records for employee numbers 101, 105, and 107.

- Option c uses the `INSERT` command to add new records with the specified `emp_number` and `emp_pct` values, which would create new entries rather than updating existing ones.

- Option d uses the `DELETE` command, which would delete records based on the given conditions, contradicting the objective of updating the `emp_pct` value for specific employees.

User Pat Lee
by
8.4k points