Background Image

FORUM

조회 수 13535 추천 수 0 댓글 1
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
FAQ & Tip 에서 확인 자료 입니다.
http://www.cubrid.com/zbxe/58122

위 방법으로는 오라클에서처럼 처리를 할 수 없다는 말씀인데.

--Case 1
create table xtbl
(
A int,
B timestamp default systimestamp not null,
C datetime default sysdatetime not null
)

--Case 2
create table xtbl2
(
A int,
B timestamp default SYS_TIMESTAMP not null,
C varchar(14) default TO_CHAR(SYS_TIMESTAMP, 'YYYYMMDDHH24MISS') not null
)

저 같은 경우는 Case 형식으로 오라클에서 사용하였습니다.
근데 Cubrid에서는 위와 같은 방법(Case 1,2)은 안되는것 같은데...

INSERT INTO TB_TMP01(A, B) VALUES(1, TO_CHAR(SYS_TIMESTAMP, 'YYYYMMDDHH24MISS'))

위와 같은 방법 밖에 없는 것인지 궁금합니다.

그리고 Cubrid에서도 저장일시와 같은 경우 위와 같이 varchar로 처리하는 것이 처리면에서나 성능상의 장점이 많은 것인지?

답변 부탁 드립니다.

감사합니다.



  • ?
    웁쓰 2010.01.08 03:14

    default sys_timestamp sysdate 경우 오라클과 다르게 작동 합니다. 테이블 생성시로 변환되어 들어가게 됩니다.
    다음의 테이블과 같이 생성이 됩니다.

    csql> ;sc test_data3
    === <Help: Schema of a Class> ===
     <Class Name>
         test_data3

    Attributes>

         int_data             INTEGER
         char_date            TIMESTAMP DEFAULT timestamp '06:05:54 PM 01/07/2010' NOT NULL

    고로 불편 하시겠지만 다음 질의처럼 매번 시간을 입력하셔야 합니다.
    INSERT INTO TB_TMP01(A, B) VALUES(1, TO_CHAR(SYS_TIMESTAMP, 'YYYYMMDDHH24MISS'))

    두번째 , 답변 입니다. 시분초를 사용하셔야 한다면 timestamp 타입을 쓰시는게 성능 향상에 도도움 될 것 같습니다. 저장되는 용량의 차이가 발생하기 때문입니다.

    다음은 테스트 결과인데 참고 하시기 바랍니다.

     

    create table test_data1

    (

    int_data int,

    char_date varchar(8) default to_char(sysdate,'YYYYMMDD') not null

    );

    insert into test_data1

    SELECT a.rnum

         , case when a.moddata = 1 then '20101201'|| '000'|| to_char(MOD(rownum,10))

                when a.moddata = 2 then '20101202'|| '000'|| to_char(MOD(rownum,10))

                  when a.moddata = 3 then '20101203'|| '000'|| to_char(MOD(rownum,10))

                when a.moddata = 4 then '20101204'|| '000'|| to_char(MOD(rownum,10))

                when a.moddata = 5 then '20101205'|| '000'|| to_char(MOD(rownum,10))

                when a.moddata = 6 then '20101206'|| '000'|| to_char(MOD(rownum,10))

                when a.moddata = 7 then '20101207'|| '000'|| to_char(MOD(rownum,10))

                when a.moddata = 8 then '20101208'|| '000'|| to_char(MOD(rownum,10))

                when a.moddata = 9 then '20101209'|| '000'|| to_char(MOD(rownum,10))

                when a.moddata = 10 then '20101210'|| '000'||to_char(MOD(rownum,10))

     else '20101211'|| '000'|| to_char(MOD(rownum,10))

     end

      from (

    SELECT rownum rnum , mod(rownum,10) moddata

    FROM table({0,1,2,3,4,5,6,7,8,9}) t0(a),

    table({0,1,2,3,4,5,6,7,8,9}) t1(a), -- 100

    table({0,1,2,3,4,5,6,7,8,9}) t2(a), -- 1,000

    table({0,1,2,3,4,5,6,7,8,9}) t3(a) -- 10,000

    ) a

    ;x

    create table test_data3

    (

    int_data int,

    char_date timestamp default systimestamp not null

    );

     

    insert into test_data3

    SELECT a.rnum

         , case when a.moddata = 1 then to_timestamp('20101201','YYYYMMDD')

                when a.moddata = 2 then to_timestamp('20101202','YYYYMMDD')

                   when a.moddata = 3 then to_timestamp('20101203','YYYYMMDD')

                when a.moddata = 4 then to_timestamp('20101204','YYYYMMDD')

                   when a.moddata = 5 then to_timestamp('20101205','YYYYMMDD')

                when a.moddata = 6 then to_timestamp('20101206','YYYYMMDD')

                   when a.moddata = 7 then to_timestamp('20101207','YYYYMMDD')

                when a.moddata = 8 then to_timestamp('20101208','YYYYMMDD')

                   when a.moddata = 9 then to_timestamp('20101209','YYYYMMDD')

                when a.moddata = 10 then to_timestamp('20101210','YYYYMMDD')

               else to_timestamp('20101211','YYYYMMDD')

               end

      from (

    SELECT rownum rnum , mod(rownum,10) moddata

    FROM table({0,1,2,3,4,5,6,7,8,9}) t0(a),

    table({0,1,2,3,4,5,6,7,8,9}) t1(a), -- 100

    table({0,1,2,3,4,5,6,7,8,9}) t2(a), -- 1,000

    table({0,1,2,3,4,5,6,7,8,9}) t3(a) -- 10,000

    ) a

    ;x

     

    $ csql -u dba index_test -S

     

            CUBRID SQL Interpreter

     

     

    Type `;help' for help messages.

     

    csql> ;info stats test_data1

     

    CLASS STATISTICS

    ****************

     Class name: test_data1 Timestamp: Thu Jan  7 18:06:23 2010

     Total pages in class heap: 416

     Total objects: 10000

     Number of attributes: 2

     Atrribute: int_data

        id: 1

        Type: DB_TYPE_INTEGER

        Mininum value: 1

        Maxinum value: 10000

        B+tree statistics:

     

     Atrribute: char_date

        id: 0

        Type: DB_TYPE_STRING

        Mininum value: Undefined

        Maxinum value: Undefined

        B+tree statistics:

            BTID: { 2 , 2856 }

            Cardinality: 10 (10) , Total pages: 21 , Leaf pages: 20 , Height: 2

     

     

     

     

    Current transaction has been committed.

    csql> ;info stats test_data3

     

    CLASS STATISTICS

    ****************

     Class name: test_data3 Timestamp: Thu Jan  7 18:06:23 2010

     Total pages in class heap: 312

     Total objects: 10000

     Number of attributes: 2

     Atrribute: char_date

        id: 0

        Type: DB_TYPE_UTIME

        Mininum value: 1291129200

        Maxinum value: 1291993200

        B+tree statistics:

     

     Atrribute: int_data

        id: 1

        Type: DB_TYPE_INTEGER

        Mininum value: 1

        Maxinum value: 10000

        B+tree statistics:

     

    오라클의 경우 http://scidb.tistory.com/entry/Varchar28-VS-Date-어느-것이-우월한가

    에서 장단점을 확인 하시길 바랍니다.

     

    즐거운 하루 되세요.


List of Articles
번호 제목 글쓴이 날짜 조회 수
공지 CUBRID 사용자를 위한 DBeaver 도구 출시 안내 admin 2024.04.23 43
공지 SQLGate for CUBRID 영구 무료 라이선스 제공 file admin 2020.04.09 4458
1034 4.0 HA ha_db_list 설정 관련 질문드립니다. 7 반짝이 2011.07.08 24401
1033 php driver interface...x64 4 platanus 2011.07.08 7661
1032 참조를 이용해서 찾을때 인덱스를 태울려면 어떻게 하나요? 2 안지민 2011.07.08 7538
1031 큐브리드 서비스 시작시 오류메시지 해결 방법 5 종이 2011.07.05 13596
1030 Sulinux 64Bit 와 CUBRID 4.0 정식 버젼 체크좀 부탁드립니다... 5 반짝이 2011.07.05 8446
1029 CUBRID 4.0 64bit & SULinux 2.0 64Bit service start 시 manager fail 발생합니다.. 2 반짝이 2011.07.02 10058
1028 cci_connect 의 에러코드에 관하여 질문드립니다 7 엥꼬 2011.06.29 9886
1027 csql 로 demodb 접속 시 오류 입니다~! 1 하하보이 2011.06.29 12110
1026 R3.1 64비트 서브쿼리 관련 문의 드립니다 2 hj 2011.06.28 7938
1025 php 모듈 로드 문제 입니다. 2 하하보이 2011.06.28 9267
1024 Table primary key잡는 중 중단 시키고, 서버 재시작하니 에러나고 시작이 안되네요. 1 미스터투 2011.06.28 7762
1023 4.0 정식판은 언제쯤 나올까요? 2 유니콘 2011.06.28 7945
1022 Connect Error 1 제이씨씨 2011.06.24 14381
1021 ERROR(196623) 무슨에러인가요? 1 닉넴 2011.06.24 9306
1020 IIS 7.5 x64 / PHP 5.3 x64 / Cubrid R4.0 x64... 1 platanus 2011.06.23 12008
1019 큐브리드매니저에서 dba암호를 걸어버리면 연결할수 없다.브로커와 구동상태를 점검하라. 이렇게 오류가 나오네요 2 블루토토 2011.06.23 10035
1018 연결(Connection)을 얻을 수 없습니다. 브로커와 서버의 구동 상태를 점검하십시오. 이 에러가 납니다 3 블루토토 2011.06.22 13868
1017 PHP에서 CUBRID 4.0 모듈이 로드 되지 않습니다. 1 file 유리심장 2011.06.22 11277
1016 DB MS949를 UTF로 변환 하는 방법이 궁굼합니다. 1 dktk 2011.06.21 13428
1015 큐브리드매니저에서 질의결과가 나타나지 않습니다. 3 file 미스터투 2011.06.19 9112
Board Pagination Prev 1 ... 144 145 146 147 148 149 150 151 152 153 ... 200 Next
/ 200

Contact Cubrid

대표전화 070-4077-2110 / 기술문의 070-4077-2113 / 영업문의 070-4077-2112 / Email. contact_at_cubrid.com
Contact Sales