Oracle SQL200 스크립트 > 임시

본문 바로가기


CAD & IT 전문교육원
송현컴퓨터학원
T 054 . 852 . 8048
공지사항 | 수강문의 | 취업정보


 

container
>

임시

Oracle SQL200 스크립트

페이지 정보

작성자 송현컴관리자 작성일22-10-30 23:52 조회1,237회 댓글0건

본문

alter session set nls_Date_format='RR/MM/DD';
drop table emp;
drop table dept;


CREATE TABLE DEPT
       (DEPTNO number(10),
        DNAME VARCHAR2(14),
        LOC VARCHAR2(13) );


INSERT INTO DEPT VALUES (10, 'ACCOUNTING', 'NEW YORK');
INSERT INTO DEPT VALUES (20, 'RESEARCH',   'DALLAS');
INSERT INTO DEPT VALUES (30, 'SALES',      'CHICAGO');
INSERT INTO DEPT VALUES (40, 'OPERATIONS', 'BOSTON');

CREATE TABLE EMP (
 EMPNO               NUMBER(4) NOT NULL,
 ENAME               VARCHAR2(10),
 JOB                 VARCHAR2(9),
 MGR                 NUMBER(4) ,
 HIREDATE            DATE,
 SAL                 NUMBER(7,2),
 COMM                NUMBER(7,2),
 DEPTNO              NUMBER(2) );


INSERT INTO EMP VALUES (7839,'KING','PRESIDENT',NULL,'81-11-17',5000,NULL,10);
INSERT INTO EMP VALUES (7698,'BLAKE','MANAGER',7839,'81-05-01',2850,NULL,30);
INSERT INTO EMP VALUES (7782,'CLARK','MANAGER',7839,'81-05-09',2450,NULL,10);
INSERT INTO EMP VALUES (7566,'JONES','MANAGER',7839,'81-04-01',2975,NULL,20);
INSERT INTO EMP VALUES (7654,'MARTIN','SALESMAN',7698,'81-09-10',1250,1400,30);
INSERT INTO EMP VALUES (7499,'ALLEN','SALESMAN',7698,'81-02-11',1600,300,30);
INSERT INTO EMP VALUES (7844,'TURNER','SALESMAN',7698,'81-08-21',1500,0,30);
INSERT INTO EMP VALUES (7900,'JAMES','CLERK',7698,'81-12-11',950,NULL,30);
INSERT INTO EMP VALUES (7521,'WARD','SALESMAN',7698,'81-02-23',1250,500,30);
INSERT INTO EMP VALUES (7902,'FORD','ANALYST',7566,'81-12-11',3000,NULL,20);
INSERT INTO EMP VALUES (7369,'SMITH','CLERK',7902,'80-12-09',800,NULL,20);
INSERT INTO EMP VALUES (7788,'SCOTT','ANALYST',7566,'82-12-22',3000,NULL,20);
INSERT INTO EMP VALUES (7876,'ADAMS','CLERK',7788,'83-01-15',1100,NULL,20);
INSERT INTO EMP VALUES (7934,'MILLER','CLERK',7782,'82-01-11',1300,NULL,10);


commit;

 

 

 

--SELECT V.ENAME, V.SAL, V.ORD FROM (SELECT ENAME, SAL, RANK() OVER (ORDER BY SAL DESC) ORD FROM EMP) V WHERE V.ORD = 1;

--SELECT JOB, SUM(SAL) FROM EMP GROUP BY JOB HAVING SUM(SAL) > (SELECT SUM(SAL) FROM EMP WHERE JOB='SALESMAN');

--SELECT ROWNUM, EMPNO,ENAME,JOB,SAL FROM EMP WHERE ROWNUM <= 5;

--SELECT EMPNO,ENAME,JOB,SAL FROM EMP ORDER BY SAL DESC FETCH FIRST 3 ROWS WITH TIES;

--select * from emp;


--select ename,sal from emp where job='ANALYST';


--SELECT JOB, SUM(SAL), MAX(SAL),MIN(SAL) FROM EMP GROUP BY JOB;

--SELECT COUNT(*) FROM EMP;


 

--SELECT SAL, ENAME FROM EMP WHERE ENAME='SCOTT' OR ENAME='KING';

 

--SELECT EMPNO, ENAME,JOB,SAL FROM EMP ORDER BY SAL DESC OFFSET 3 ROWS;

--select table_name from user_tables;  --user가 소유한 모든 테이블 조회

--alter table dept add sumsal number(10);  --dept 테이블에 sumsal필드를 추가

--update dept d set sumsal = (select sum(sal) from emp e where e.deptno = d.deptno);

 

 

댓글목록

등록된 댓글이 없습니다.

 


tail
회사소개 개인정보취급방침 CCTV운영관리방침 저작권보호정책 Copyright © www.goshc.co.kr All rights reserved.
상단으로.....
760-300 경북 안동시 경북대로 468 송현컴퓨터학원 | Tel. 054-852-8048 | Fax. 054-841-5219 | Email. nanwgis@hanmail.net
PC 버전으로 보기