varchar , text difference

BackEnd_Ash.log·2021년 7월 20일
0

database

목록 보기
15/31

📌reference site

https://congi.tistory.com/entry/Foreign-Key-%EC%84%A4%EC%A0%95-%EB%B0%A9%EB%B2%95-%EB%B0%8F-%EC%98%B5%EC%85%98-%EC%84%A4%EB%AA%85

https://chuckolet.tistory.com/71

i want to settings fk between parent table and child table By the way you know that it's usually use integer type

and we can FK to varchar type but can't use text type

📌varchar , text difference

👉 varchar

  • the varchar can be used as part of index.
  • the varchar is stored in memory and fast more than text
  • varchar: x <= 255 then, 1 byte, 256 <= x <= 65535 then, 2 byte

👉 text

  • text can not be used as part of index.
  • the text is stored in disk and slow more than varchar
  • Unconditionally 2 byte

so text is stored on disk , and if you called query frequently , it's has a big performance difference , so you should be careful about using it

so we can set varchar to FK.

profile
꾸준함이란 ... ?

0개의 댓글