w3resource

PostgreSQL Update Table - Exercises, Practice, Solution

PostgreSQL Update Table [8 exercises with solution]

1. Write a SQL statement to change the email column of the employees table with 'not available' for all employees.

Sample table : employees


Click me to see the solution

2. Write a SQL statement to change the email and commission_pct column of the employees table with 'not available' and 0.10 for all employees.

Sample table: employees


Click me to see the solution

3. Write a SQL statement to change the email and commission_pct column of the employees table with 'not available' and 0.10 for those employees whose department_id is 110.

Sample table: employees


Click me to see the solution

4. Write a SQL statement to change the email column of employees table with 'not available' for those employees whose department_id is 80 and gets a commission is less than.20%.

Sample table: employees


Click me to see the solution

5. Write a SQL statement to change the email column of the employees table with 'not available' for those employees who belongs to the 'Accounting' department.

Sample table: employees


Sample table: departments


Click me to see the solution

6. Write a SQL statement to change the salary of an employee to 8000 whose ID is 105, if the existing salary is less than 5000.

Sample table: employees


Click me to see the solution

7. Write a SQL statement to change the job ID of the employee which ID is 118 to SH_CLERK if the employee belongs to a department which ID is 30 and the existing job ID does not start with SH.

Sample table: employees


Click me to see the solution

8. Write a SQL statement to increase the salary of employees under the department 40, 90 and 110 according to the company rules that, the salary will be increased by 25% of the department 40, 15% for department 90 and 10% of the department 110 and the rest of the department will remain same.

Sample table: employees


Click me to see the solution



Follow us on Facebook and Twitter for latest update.