-- 산술 표현식 정리
select 5+2, 5-2, 5*2, 5/2 from dual; -- 산술표현식을 출력한다.

select 5/2, floor(5/2), mod(5,2)
from dual; -- floor(계산을 했을때 몫을 표시), mod(나머지 표시)

select floor(2.5), ceil(2.5)
from dual; -- floor(해당숫자보다 작은 최대의정수), ceil(해당숫자보다 큰 최소의 정수)

select 0, 5+null, 5*null, 5-null, 5/null
from dual; -- null(존재하지 않는값으로 연산에 추가되면 무조건 null출력)

select ename, sal, comm
from emp;

select ename, sal, comm, sal+comm
from emp;

select null, nvl(null, 0), nvl(null, 'null이군요') -- nvl(x,y) : x의 결과물이 null이라면 y로 나타내라
from dual;

select ename, sal, comm, sal+nvl(comm, 0) -- comm이 null 일때 sal과 sal의 합을 구한다.
from emp;

select ename "사원명", sal, comm, sal*12+nvl(comm, 0) "연봉" -- comm이 null 일때 sal과 sal의 합을 구한다.
from emp; -- column명 as "별칭" (as는 생략가능) (" "도 생략가능하나 공백이 있으면 ""를 해야한다):alias(별칭)

select ename, sal*12+nvl(comm,0) "연봉",
       nvl2(comm, sal*12+comm, sal*12) "연봉2",
       -- nvl2(x,y,z) : x의 값이 null이 아니라면 y의 수식을 나타내고, null이라면 z의 수식을 나타내라
       coalesce(sal*12+comm, sal*12, 0) "연봉3"
       -- coalesce(x,y,z) : x의 값이 null이라면 y로 나타내고, y마저 null이라면 z로 나타태라
from emp;

'Program... > Oracle' 카테고리의 다른 글

Oracle 중복행 제거  (0) 2009.03.13
Oracle 연결 연산자  (0) 2009.03.13
Oracle 계정관리 및 복구 & 백업  (0) 2009.03.13
ER-WIN 사용방법  (0) 2009.03.13
DB 논리적 모델링 (용어해설)  (0) 2009.03.13
Posted by Duritz

  [ 백업/복구 및 계정생성 ]


1. 계정 관리 (SQL-PLUS)
  (1) 생성
  
     <1> 사용자 생성
       SQL>CONN SYSTEM/pwd       -- DBA Role이 있는 유저로 접속합니다.
       SQL>CREATE USER TEST IDENTIFIED BY TEST;    -- USER를 다시 생성합니다.

     <2> 접근
       SQL> CONN TEST/TEST - 연결 실패!!

       SQL> CONN SYSTEM/pwd   -- 권한 부여기능이 있는 유저로 접속
       SQL> GRANT connect, resource TO TEST; -- 권한 부여
       SQL> CONN TEST/TEST - 연결 성공!!
 
     <3> 확인
       SQL> CONN SYSTEM/pwd
       SQL> SELECT username, default_tablespace, temporary_tablespace FROM DBA_USERS;


   (2) 수정
     <1> 접속
       SQL>CONN SYSTEM/pwd       -- SYSTEM USER로 접속

     <2> 비밀번호 수정
       SQL>ALTER USER scott IDENTIFIED BY lion;    -- scott USER의 비밀번호 수정
 
     <3> 수정된 계정으로 연결 확인 
       SQL>conn scott/lion    

     <4> 원래 비번으로 다시 수정
       SQL>ALTER USER scott IDENTIFIED BY tiger;  -- scott USER의 비밀번호 원래값으로 수정


   (3) 삭제
     <1> 접속
        SQL>CONN SYSTEM/pwd

     <2> 삭제
        SQL> DROP USER test CASCADE;

     <3> 확인
        SQL>CONN SYSTEM/pwd
        SQL> SELECT username, default_tablespace, temporary_tablespace FROM DBA_USERS;


2. 백업 및 복구 (도스 컨솔) 
  (1) 백업

    <1> 전체 데이터베이스 [ Full Level Export ]
      C:\>exp  userid=system/pwd  file='C:\SOO\ORACLE\day11\dump1.dmp'   full=y

    <2> 특정 사용자 [ User Level Export ]
      C:\>exp scott/tiger file='C:\SOO\ORACLE\day11\dump2.dmp'
      또는,
      C:\>exp userid=system/pwd owner=scott  file='C:\SOO\ORACLE\day11\dump2_1.dmp'

    <3> 선택된 테이블 [Table Level Export]
      C:\>exp userid=system/pwd file='C:\SOO\ORACLE\day11\dump3.dmp' tables=(scott.EMP, scott.DEPT) //잘 안됨
      또는
      C:\>exp userid=scott/tiger file='C:\SOO\ORACLE\day11\dump3_1.dmp' tables=(EMP, DEPT) log=exp.log


 
  (2) 복구 
   
     <1> 전체 데이터베이스 [ Full Level Import ]
       C:\>imp userid=system/pwd file='C:\SOO\ORACLE\day11\dump1.dmp'  full=y


     <2> 특정 사용자 [ User Level Import ]
       C:\>imp userid=scott/tiger file='C:\SOO\ORACLE\day11\dump2.dmp'

     <3> 다른 사용자에게 IMPORT [ User Level Import ]
       ==> scott유저의 데이터를 EXPORT받아서 test 유저에게 IMPORT하는 예

       C:\>exp userid=system/pwd file='C:\SOO\ORACLE\day11\scott.dmp' owner=scott
       C:\>imp userid=system/pwd file='C:\SOO\ORACLE\day11\scott.dmp' fromuser=scott touser=test   

 

     

 

   cf) 추천사이트  : http://www.oracleclub.com/ -> 오라클 강좌

'Program... > Oracle' 카테고리의 다른 글

Oracle 연결 연산자  (0) 2009.03.13
Oracle 산술 표현식  (0) 2009.03.13
ER-WIN 사용방법  (0) 2009.03.13
DB 논리적 모델링 (용어해설)  (0) 2009.03.13
Tablespace 오류복구  (0) 2009.03.13
Posted by Duritz

'Program... > Oracle' 카테고리의 다른 글

Oracle 산술 표현식  (0) 2009.03.13
Oracle 계정관리 및 복구 & 백업  (0) 2009.03.13
DB 논리적 모델링 (용어해설)  (0) 2009.03.13
Tablespace 오류복구  (0) 2009.03.13
오라클 백업복구  (0) 2009.03.13
Posted by Duritz

공지사항

Yesterday
Today
Total
05-18 14:19

달력

 « |  » 2024.5
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31