Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Challenge: Creating After Trigger | Some Additional Topics
Advanced Techniques in SQL
course content

Зміст курсу

Advanced Techniques in SQL

Advanced Techniques in SQL

1. ACID
2. Query optimization.Indexes
3. Some Additional Topics

bookChallenge: Creating After Trigger

Завдання

Now we will create a trigger to execute after updating the balance column of the BankAccounts table.
When triggered, it will invoke the function after_update_balance(), which logs the account number and the new balance into the UserLogs table, providing a record of balance modifications. The key idea is that we don't have to manually fill in the logs table - it will be done automatically by the trigger.

Note

Pay attention that triggers created for UPDATE operations can be designed to work only for update of the particular column. We can use the following statement to achive this:
CREATE TRIGGER trigger_name AFTER UPDATE OF col_name ON table_name.

Your task is to:

  • Create the after_update_balance() function. It should return a trigger as its result and perform the necessary action, which is updating logs.
  • Create an AFTER UPDATE trigger on the bankaccounts table. This trigger should use the designed function by executing it on each row of the update statement.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 3. Розділ 2
toggle bottom row

bookChallenge: Creating After Trigger

Завдання

Now we will create a trigger to execute after updating the balance column of the BankAccounts table.
When triggered, it will invoke the function after_update_balance(), which logs the account number and the new balance into the UserLogs table, providing a record of balance modifications. The key idea is that we don't have to manually fill in the logs table - it will be done automatically by the trigger.

Note

Pay attention that triggers created for UPDATE operations can be designed to work only for update of the particular column. We can use the following statement to achive this:
CREATE TRIGGER trigger_name AFTER UPDATE OF col_name ON table_name.

Your task is to:

  • Create the after_update_balance() function. It should return a trigger as its result and perform the necessary action, which is updating logs.
  • Create an AFTER UPDATE trigger on the bankaccounts table. This trigger should use the designed function by executing it on each row of the update statement.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 3. Розділ 2
toggle bottom row

bookChallenge: Creating After Trigger

Завдання

Now we will create a trigger to execute after updating the balance column of the BankAccounts table.
When triggered, it will invoke the function after_update_balance(), which logs the account number and the new balance into the UserLogs table, providing a record of balance modifications. The key idea is that we don't have to manually fill in the logs table - it will be done automatically by the trigger.

Note

Pay attention that triggers created for UPDATE operations can be designed to work only for update of the particular column. We can use the following statement to achive this:
CREATE TRIGGER trigger_name AFTER UPDATE OF col_name ON table_name.

Your task is to:

  • Create the after_update_balance() function. It should return a trigger as its result and perform the necessary action, which is updating logs.
  • Create an AFTER UPDATE trigger on the bankaccounts table. This trigger should use the designed function by executing it on each row of the update statement.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Завдання

Now we will create a trigger to execute after updating the balance column of the BankAccounts table.
When triggered, it will invoke the function after_update_balance(), which logs the account number and the new balance into the UserLogs table, providing a record of balance modifications. The key idea is that we don't have to manually fill in the logs table - it will be done automatically by the trigger.

Note

Pay attention that triggers created for UPDATE operations can be designed to work only for update of the particular column. We can use the following statement to achive this:
CREATE TRIGGER trigger_name AFTER UPDATE OF col_name ON table_name.

Your task is to:

  • Create the after_update_balance() function. It should return a trigger as its result and perform the necessary action, which is updating logs.
  • Create an AFTER UPDATE trigger on the bankaccounts table. This trigger should use the designed function by executing it on each row of the update statement.

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Секція 3. Розділ 2
Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
some-alt