标签:src iso load color expr rmi sample first database
1.With reference to the sample HR Schema in Oracle Express 18c docker container, write the SQL query statements AND capture a screenshot of the output of your queries in SQL Developer.
a)Show the EMPLOYEE_ID, FIRST_NAME, LAST_NAME and DEPARTMENT_NAME of the employees who are the manager of at least one other employees in the department. The result should be sorted in ascending EMPLOYEE_ID.
select employees.employee_id,employees.first_name,employees.last_name,departments.department_name from employees inner join departments on employees.department_id=departments.department_id where employees.employee_id in( select a.employee_id from employees a,employees b where a.employee_id=b.manager_id group by a.employee_id ) order by employees.employee_id asc ;
b)For each department, show the city where the department is located and the number of employees in the department, sorted by decreasing number of employees in the department followed by ascending department name (if two departments have the same number of employees).
select department_name department, locations.city city,count(employees.department_id) count from departments join employees on departments.department_id=employees.department_id join locations on locations.location_id=departments.location_id group by department_name,locations.city order by count desc, departments.department_name asc;
c)For each department with more than 3 employees whose salary is higher than the average salary of the company, show the number the number of employees whose salary is higher than the average salary of the company.
with tmp(avg_sal,department_id) as (select avg(salary) avg_sal,department_id from employees group by department_id) select department_id,count(employee_id) from employees natural join tmp where salary>avg_sal group by department_id having count(employee_id)>3
d) For each department, show the first name and last name of the employee whose salary is higher than all employees in that department. The result should be ordered by ascending department name. You should ignore those departments in which none of the employee’s salary is known.
select department_name as Department,first_name as First_Name,last_name as Last_Name ,salary from employees emp join departments dept on emp.department_id = dept.department_id where (emp.department_id ,emp.salary) in (select department_id ,max(Salary) as Salary from employees group by department_id ) order by department_name asc ;
2.Implement the following requirements in the PDB XEPDB1 in Oracle docker container.
? Create local users Tim, Joe and Mavis
? Tim and Joe are assigned the programmer role
? Mavis is assigned the supervisor role
? Users assigned a local programmer role should be able to establish a connection to Oracle Database Server, create tables in his/her own user account select/updating/inserting/deleting from the table created by him/her, and dropping the tables created by him/her.
? Users assigned the supervisor role get all the permissions assigned to programmer role as well as the privilege to execute select query on all the tables in the pluggable database.
缺少授权查询的图
a) Provide the SQL statements to create the users/roles and grant appropriate permission.
b) After executing the various SQL statements in part (a), what SQL statements should we use to check whether the roles/permissions are created/assigned appropriately? Discuss the purpose of the SQL statements and the output of the corresponding statements in SQL Developer.
查看用户或者角色系统权限
select * from dba_sys_privs;
select * from user_sys_privs;
查看角色包含的权限
select * from role_sys_privs
标签:src iso load color expr rmi sample first database
原文地址:https://www.cnblogs.com/ak918xp/p/13839212.html