I have a emp table.I want to display columns empno as emp_number,ename as emp_name,job as emp_job,mgr as emp_manager,hiredate as emp_hiredate,sal as emp_salary,comm as emp_commission,deptno as emp_department in view. Renaming columns in views will help increase security of sensitive tables and hiding columns under alias names.In this scenario we have to create view like below.
empno | ename | job | mgr | hiredate | sal | comm | deptno |
---|---|---|---|---|---|---|---|
7788 | SCOTT | ANALYST | 7566 | 19/04/1987 | 3000 | 0 | 20 |
7782 | CLARK | MANAGER | 7839 | 09/06/1981 | 2450 | 0 | 10 |
7521 | WARD | SALESMAN | 7698 | 22/02/1981 | 1250 | 500 | 30 |
7698 | BLAKE | MANAGER | 7839 | 01/05/1981 | 2850 | 0 | 30 |
7902 | FORD | ANALYST | 7566 | 03/12/1981 | 3000 | 0 | 20 |
7839 | KING | PRESIDENT | 0 | 17/09/1981 | 5000 | 0 | 10 |
7900 | JAMES | CLERK | 7698 | 03/12/1981 | 950 | 0 | 30 |
7654 | MARTIN | SALESMAN | 7698 | 28/09/1981 | 1250 | 1400 | 30 |
7934 | MILLER | CLERK | 7782 | 23/01/1982 | 1300 | 0 | 10 |
7566 | JONES | MANAGER | 7839 | 02/04/1981 | 2975 | 0 | 20 |
7844 | TURNER | SALESMAN | 7698 | 08/09/1981 | 500 | 0 | 30 |
7499 | ALLEN | SALESMAN | 7698 | 20/02/1981 | 1600 | 300 | 30 |
7876 | ADAMS | CLERK | 7788 | 23/05/1987 | 1100 | 0 | 20 |
AS SELECT
EMPNO
,ENAME
,JOB
,MGR
,HIREDATE
,SAL
,COMM
,DEPTNO FROM EMP;
run the below query, only alias columns are displayed.
emp_number | emp_name | emp_job | emp_manager | emp_hiredate | emp_salary | emp_commission | emp_department | |
---|---|---|---|---|---|---|---|---|
7788 | SCOTT | ANALYST | 7566 | 19/04/1987 | 3000.00 | 0 | 20 | |
7782 | CLARK | MANAGER | 7839 | 09/06/1981 | 2450.00 | 0 | 10 | |
7521 | WARD | SALESMAN | 7698 | 22/02/1981 | 1250.00 | 500.00 | 30 | |
7698 | BLAKE | MANAGER | 7839 | 01/05/1981 | 2850.00 | 0 | 30 | |
7902 | FORD | ANALYST | 7566 | 03/12/1981 | 3000.00 | 0 | 20 | |
7839 | KING | PRESIDENT | 0 | 17/09/1981 | 5000.00 | 0 | 10 | |
7900 | JAMES | CLERK | 7698 | 03/12/1981 | 950.00 | 0 | 30 | |
7654 | MARTIN | SALESMAN | 7698 | 28/09/1981 | 1250.00 | 1400.00 | 30 | |
7934 | MILLER | CLERK | 7782 | 23/01/1982 | 1300.00 | 0 | 10 | |
7566 | JONES | MANAGER | 7839 | 02/04/1981 | 2975.00 | 0 | 20 | |
7844 | TURNER | SALESMAN | 7698 | 08/09/1981 | 500.00 | 0.00 | 30 | |
7499 | ALLEN | SALESMAN | 7698 | 20/02/1981 | 1600.00 | 300.00 | 30 | |
7876 | ADAMS | CLERK | 7788 | 23/05/1987 | 1100.00 | 0 | 20 |
No comments:
Post a Comment