Background Image

FORUM

2023.04.24 13:00

Fk값 가져오기

조회 수 166 추천 수 0 댓글 2
?

단축키

Prev이전 문서

Next다음 문서

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


* 질문 등록 시 다음의 내용을 꼭 기입하여 주세요.

OS

Window7 32bit, Linux 64bit 등

CUBRID Ver.

[cubrid_rel] 수행 결과

CUBRID TOOL Ver.

[도움말]-[버전정보] 확인

응용 환경(API)

java, php, odbc 등 입력


* CUBRID 응용 오류, SQL 오류 또는 SQL 튜닝 관련된 문의는 반드시 다음의 내용을 추가해 주세요. 비밀글이나 비밀 댓글도 가능합니다.
* 저희가 상황을 이해하고, 재현이 가능해야 알 수 있는 문제들이 많습니다. 가능한 정보/정황들을 부탁합니다.


에러 내용 및 재현 방법재현 가능한 Source와 SQL
관련 테이블(인덱스, 키정보 포함) 정보CUBRID 홈 디렉토리 아래 log 디렉토리 압축


-------------- 아래에 질문 사항을 기입해 주세요. ------------------------------------------------------------------------jdbc api를 사용하여 테이블 fk를 뽑아내려 합니다. getImportedKeys로 받아서 처리하려고 하는데 어떻게 해야 되나요? 예제 소스에는 Test.printFkInfo(rs)로 되어있습니다



  • ?

    안녕하세요.

     

    11.2 버전 전과 후로 차이가 있습니다.

     

    11.2 버전부터는 사용자를 스키마 개념으로 사용하기 때문에 테이블명에 소유자 이름을 스키마 이름으로 지정해주셔야 합니다.
    접속하는 사용자가 테이블의 소유자인 경우에는 테이블명만 넣어주실 수 있습니다.

     

    소유자가 u1 사용자인 t1_pk과 t1_fk 테이블이 있을 때
    11.2 이전 버전과 이후 버전에서 getImportedKeys 함수를 실행하는 방법을 참고해주세요.

     

    u1 사용자를 생성하고, u1 사용자로 접속해서  t1_pk과 t1_fk 테이블을 생성합니다.

    csql -u dba demodb
    csql> create user u1;
    
    csql -u u1 demodb
    csql> create table t1_pk (c1 int primary key); /* owner: u1 */
    csql> create table t2_fk (c1 int primary key, c2 int references t1_pk); /* owner: u1 */

     

    11.2 이전 버전에서는 어떤 사용자로 접속했는지에 관계 없이 테이블명만 넣어주실 수 있었습니다.

    Connection connection = DriverManager.getConnection("jdbc:cubrid:192.168.xxx.xxx:33000:demodb:::", "dba", "");
    ResultSet resultSet = databaseMetaData.getImportedKeys(null, null, "t2_fk");

     

    11.2 이후 버전에서는 어떤 사용자로 접속했는지에 따라서 테이블명에 소유자 이름을 스키마 이름으로 지정해주셔야 합니다.

    /* dba 사용자로 접속하여 u1.t2_fk 테이블 확인. */
    Connection connection = DriverManager.getConnection("jdbc:cubrid:192.168.xxx.xxx:33000:demodb:::", "dba", "");
    ResultSet resultSet = databaseMetaData.getImportedKeys(null, null, "u1.t2_fk");
    
    /* u1 사용자로 접속하여 t2_fk 테이블 확인. */
    Connection connection = DriverManager.getConnection("jdbc:cubrid:192.168.xxx.xxx:33000:demodb:::", "u1", "");
    ResultSet resultSet = databaseMetaData.getImportedKeys(null, null, "t2_fk");

     

    감사합니다.

  • ?
    오명환 2023.04.24 15:19
    매뉴얼 예제에서 사용한 printFKInfo() 코드입니다. 참고하세요.

    public static void printFkInfo(ResultSet rs)
    throws Exception {
    while(rs.next()) {
    System.out.println("<" + rs.getString("FK_NAME") + ">");
    System.out.println("01. PKTABLE_CAT : " + rs.getString("PKTABLE_CAT"));
    System.out.println("02. PKTABLE_SCHEM : " + rs.getString("PKTABLE_SCHEM"));
    System.out.println("03. PKTABLE_NAME : " + rs.getString("PKTABLE_NAME"));
    System.out.println("04. PKCOLUMN_NAME : " + rs.getString("PKCOLUMN_NAME"));
    System.out.println("05. FKTABLE_CAT : " + rs.getString("FKTABLE_CAT"));
    System.out.println("06. FKTABLE_SCHEM : " + rs.getString("FKTABLE_SCHEM"));
    System.out.println("07. FKTABLE_NAME : " + rs.getString("FKTABLE_NAME"));
    System.out.println("08. FKCOLUMN_NAME : " + rs.getString("FKCOLUMN_NAME"));
    System.out.println("09. KEY_SEQ : " + rs.getString("KEY_SEQ"));
    System.out.println("10. UPDATE_RULE : " + CubridSUS434.getRuleName(rs.getString("UPDATE_RULE")));
    System.out.println("11. DELETE_RULE : " + CubridSUS434.getRuleName(rs.getString("DELETE_RULE")));
    System.out.println("12. FK_NAME : " + rs.getString("FK_NAME"));
    System.out.println("13. PK_NAME : " + rs.getString("PK_NAME"));
    System.out.println("14. DEFERRABILITY : " + CubridSUS434.getDeferrabilityName(rs.getString("DEFERRABILITY")));
    }
    }

  1. CUBRID 사용자를 위한 DBeaver 도구 출시 안내

    Date2024.04.23 Byadmin Views55
    read more
  2. SQLGate for CUBRID 영구 무료 라이선스 제공

    Date2020.04.09 Byadmin Views4461
    read more
  3. 데이터 이관 문의입니다.

    Date2023.05.30 Bykipo0821 Views131
    Read More
  4. 8.4.4 charset. Collation 확인 방법

    Date2023.05.24 By네오랜덤 Views188
    Read More
  5. 8.4.4버젼 charset 확인

    Date2023.05.23 By네오랜덤 Views193
    Read More
  6. 쿼리 속도 차이 질문

    Date2023.05.18 By하얀미스 Views143
    Read More
  7. spring boot 에서 HikariPool-1 - Driver does not support get/set network timeout for connections. (java.lang.UnsupportedOperationException) 질문 드립니다.

    Date2023.05.18 Bykjaminam Views787
    Read More
  8. cci 프로그래밍에서 DB LINK 관련 문의

    Date2023.05.18 Byjjune1206 Views131
    Read More
  9. 큐브리드 매니저 실행이 오류

    Date2023.05.18 By청주시청 Views102
    Read More
  10. ddl 추출

    Date2023.05.17 By네오랜덤 Views105
    Read More
  11. 하나의 쿼리에서 복수 테이블 업데이트 방법 문의

    Date2023.05.17 By도담도담 Views137
    Read More
  12. cubrid driver 설치 문의

    Date2023.05.08 By고구망구망 Views438
    Read More
  13. 큐브리드 매니저 접속 이 안됩니다. 확인 요청 드립니다.

    Date2023.04.28 By뿡이 Views128
    Read More
  14. Fk값 가져오기

    Date2023.04.24 By네오랜덤 Views166
    Read More
  15. 서버 메모리 교체 및 ha 상 데이터 삭제 절차

    Date2023.04.20 By레피엘 Views113
    Read More
  16. java stored procedure 에 loadjava 로 jar 파일 로드 시 java.lang.ClassNotFoundException 에러 문의

    Date2023.04.18 By개미가불쌍해 Views147
    Read More
  17. Cubrid stored procedure 스케쥴 등록 형식

    Date2023.04.17 ByRoy Views112
    Read More
  18. 암호화 함수 MDB_ENC 질문입니다

    Date2023.04.17 ByBE-DEV Views82
    Read More
  19. auto_increment 추가 방법 문의

    Date2023.04.14 By부패방지운영팀 Views265
    Read More
  20. CUBRID 사용자 계정 생성 관련 문의

    Date2023.04.14 By몽키스패너 Views132
    Read More
  21. order by 이후 rownum이 의도와 다르게 찍힙니다.

    Date2023.04.14 By바보똥개 Views143
    Read More
  22. 백업 및 복구 시 cubrid 버전 간 호환 문의

    Date2023.04.13 By플레이어블 Views71
    Read More
Board Pagination Prev 1 ... 3 4 5 6 7 8 9 10 11 12 ... 200 Next
/ 200

Contact Cubrid

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