본문 바로가기
공부/WEB개발 과제

File Upload BLOB / CLOB

by TILDA_16 2023. 6. 14.

기존의 게시글에서는 간단한 파일 업로드 기능만 만들었다.

 

따라서 이번엔 BLOB와 CLOB를 구현해보려고 한다.

 

CLOB / BLOB 데이터 유형과 그 크기는 필요에 따라 적절하게 사용하면 된다.

 

https://dev.mysql.com/doc/refman/5.7/en/storage-requirements.html

 

MySQL :: MySQL 5.7 Reference Manual :: 11.7 Data Type Storage Requirements

11.7 Data Type Storage Requirements The storage requirements for table data on disk depend on several factors. Different storage engines represent data types and store raw data differently. Table data might be compressed, either for a column or an entire

dev.mysql.com

 

 

먼저 varchar로 저장되어 있는 파일타입을 BLOB로 변경을 해줬다.

 

file 컬럼 변경 BLOB

 

기존의 파일 업로드 기능이 구현돼서 구현하는데 어려움은 없었다.

 

Oracle에서는 대용량 데이터 타입으로 BLOB와 CLOB를 사용하면 되고

 

Mysql에서는 대용량 데이터 타입으로 BLOB와 Text(MEDIUMTEXT, TINYTEXT)를 사용하면 된다.

 

https://dev.mysql.com/doc/refman/5.7/en/storage-requirements.html

 

MySQL :: MySQL 5.7 Reference Manual :: 11.7 Data Type Storage Requirements

11.7 Data Type Storage Requirements The storage requirements for table data on disk depend on several factors. Different storage engines represent data types and store raw data differently. Table data might be compressed, either for a column or an entire

dev.mysql.com

 

마찬가지로 데이터 타입을 TEXT(CLOB)로 변경하였다.

 

file 컬럼 변경 CLOB(text)

 

이러한 방법으로 BLOB와 CLOB로 파일을 업로드할 수 있다.