Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Write a script that creates a user-defined database role named PaymentEntry i

ID: 3546655 • Letter: 1

Question

1. Write a script that creates a user-defined database role named PaymentEntry in the AP database. Give UPDATE permission to the new role for the Invoices table, UPDATE and INSERT permission for the InvoiceLineItems table, and SELECT permission for all user tables.


2. Write a script that (1) creates a login ID named "AAaron" with the password "aaar999"; (2) sets the default database for the login to the AP database; (3) creates a user named "Aaron" for the login; and (4) assigns the user to the PaymentEntry role you created in exercise1.


4. Using the Management Studio, create a login ID named "FFalk" with the password "ffal9999", and set the default database to the AP database. Then, create a user for the login ID named "FFalk" and assign the user to the PaymentEntry role you created in exercise1.

Explanation / Answer

1) create role PaymentEntry identified by PaymentEntry ;


grrant update on Invoices to PaymentEntry;

grrant insert,update on InvoiceLineItems to PaymentEntry;

******************

declare

begin

FOR x IN (SELECT * FROM user_tables)

LOOP

EXECUTE IMMEDIATE 'GRANT SELECT ON ' || x.table_name || ' TO PaymentEntry';

END LOOP;

end;

2. Write a script that (1) creates a login ID named "AAaron" with the password "aaar999"; (2) sets the default database for the login to the AP database; (3) creates a user named "Aaron" for the login; and (4) assigns the user to the PaymentEntry role you created in exercise1.


(1).,(2). create user AAaron@AP identfied by aaar999;

(3) Already created in (1)

(4)grant PaymentEntry to AAaron;


(4) Using the Management Studio, create a login ID named "FFalk" with the password "ffal9999", and set the default database to the AP database. Then, create a user for the login ID named "FFalk" and assign the user to the PaymentEntry role you created in exercise1.


Ans) create user FFalk@AP identified by ffal9999;

grant PaymentEntry to FFalk;