본문 바로가기
Spring/Spring Boot

H2 DBMS 파일모드 사용 시 DB파일 경로

by YellowCow 2022. 8. 13.

H2 DBMS 파일모드 사용 시,

DB파일이 어느 위치에 생성되는지 알기 위해 정리한다.

 

아래 글은 H2 DBMS 매뉴얼에 있는 내용이다

Where are the Database Files Stored?
When using database URLs like jdbc:h2:~/test, the database is stored in the user directory.
For Windows, this is usually C:\Documents and Settings\ or C:\Users\.
If the base directory is not set (as in jdbc:h2:./test), the database files are stored in the directory where the application is started (the current working directory).
When using the H2 Console application from the start menu, this is /bin.
The base directory can be set in the database URL.
A fixed or relative path can be used.
When using the URL jdbc:h2:file:./data/sample, the database is stored in the directory data (relative to the current working directory).
The directory is created 424 of 428 automatically if it does not yet exist.
It is also possible to use the fully qualified directory name (and for Windows, drive name).
Example: jdbc:h2:file:C:/data/test

 

번역하자면,

  • 파일 경로를 "jdbc:h2:~/"으로 할 경우, 유저 디렉토리에 저장됨
  • "jdbc:h2:./"와 같이, 베이스 디렉토리가 지정되지 않을 경우, 현재 H2 DBMS가 실행된 경로에 저장됨
  • 절대/상대경로 모두 사용될 수 있다
  • 전체경로로 파일 경로를 설정할 수 있다

 

DB 파일이 저장되는 규칙은 아래와 같다

 

댓글