메뉴 건너뛰기

조회 수 7168 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

MySQL 기반의 제로보드 게시판을 오라클로 옮길때 몇가지 문제점 중 하나.

게시물 등록일자인 reg_date 필드가 속성이 int(13) 형으로 실제 데이터를 보면

1294018642

이처럼 들어간다.

이 숫자는 UNIX 시스템 타임인데

1970년 1월 1일을 기준으로 누적된 초이다.

오라클로 변환할 경우 그냥 number 타입 같은거로 써도 되지만

date 형으로 변환할 방법을 궁리 해 봤다.

 

우선 유닉스 시간을 오라클 형으로 바꾸는 법은

select to_char(to_date('19700101000000','YYYYMMDDHH24MISS') + 1362965195 / 86400 , 'yyyy-mm-dd hh24:mi:ss') as oracle_time from dual;

이것을 참고 하여 reg_date number 형을 reg_date date 형으로 바꿔 보자

변경할 reg_date 컬럼이 있는 테이블 명이 member_table 이라고 하고

 

alter table member_table add reg_date2 date null;

update member_table set reg_date2 = to_date('19700101000000','YYYYMMDDHH24MISS') + reg_date/86400;

commit;

alter table member_table drop column reg_date;

alter table member_table add reg_date date null;

update member_table set reg_date = reg_date2;

commit;

alter table member_table modify reg_date not null;

alter table member_table drop column reg_date2;

select * from member_table;

 

사실은 컬럼의 형을 바꾸는 것은 아니고

컬럼을 새로 추가 하고 날짜 형식으로 복사하는 것이다.


  1. No Image 08Dec
    by
    2016/12/08 Views 7704 

    쿼리 파싱 시간 측정 - query parsing time

  2. No Image 08Dec
    by
    2016/12/08 Views 6908 

    SQL 작성을 위한 25가지 원칙

  3. No Image 08Dec
    by
    2016/12/08 Views 8744 

    엑셀데이타를 DB 에 저장. Excel => oracle db restore

  4. 오라클 웹로직 12.1.3 설치 방법

  5. No Image 21Sep
    by
    2016/09/21 Views 7274 

    오라클 암호를 분실한 경우 접속 방법

  6. No Image 12Sep
    by
    2016/09/12 Views 7249 

    자동증가 SEQUENCE 생성

  7. No Image 12Sep
    by
    2016/09/12 Views 7936 

    테이블 생성(다중 PK)

  8. No Image 12Sep
    by
    2016/09/12 Views 7069 

    PK 수정하기

  9. No Image 12Sep
    by
    2016/09/12 Views 7906 

    초 이하 단위 시간 얻어오기

  10. No Image 12Sep
    by
    2016/09/12 Views 8119 

    V$SESSION 테이블 활용

  11. No Image 12Sep
    by
    2016/09/12 Views 7500 

    Database link, Synonym How to

  12. No Image 12Sep
    by
    2016/09/12 Views 6968 

    아카이브 백업 / 복구

  13. No Image 12Sep
    by
    2016/09/12 Views 8045 

    cron을 이용한 Oracle 백업

  14. No Image 12Sep
    by
    2016/09/12 Views 8924 

    시퀀스 초기화 프로시저

  15. No Image 12Sep
    by
    2016/09/12 Views 8229 

    TOAD에서 Explain Plan 보기

  16. No Image 12Sep
    by
    2016/09/12 Views 7411 

    Create SYNONYM

  17. No Image 12Sep
    by
    2016/09/12 Views 7015 

    DB Link How-To

  18. 다른 버전의 오라클 import, export 하기

  19. No Image 12Sep
    by 조쉬
    2016/09/12 Views 7168 

    제로보드 reg_date 필드 date 형으로 변환하기

  20. No Image 12Sep
    by
    2016/09/12 Views 10980 

    오라클 인스턴스 클라이언트(oracle instant client)

Board Pagination Prev 1 2 3 4 5 6 7 Next
/ 7

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved