24 Nisan 2023 Pazartesi

Sütun Tipleri - Non-Binary String Tipleri

Giriş
Açıklaması şöyle. String tipleri temelde nonbinary ve binary olarak ayrılıyorlar
The string data types are CHAR, VARCHAR, BINARY, VARBINARY, BLOB, TEXT, ENUM, and SET.
CHAR Tipi
Açıklaması şöyle. CHAR en fazla 255 karakter olabilir. Bu sütun tipi için illaki bir uzunluk belirtmek lazım
A fixed-length nonbinary (character) string
VARCHAR Tipi
Açıklaması şöyle. VARCHAR en fazla 65,535 karakter olabilir. Bu sütun tipi için illaki bir uzunluk belirtmek lazım
A variable-length nonbinary (character) string
CHAR vs VARCHAR
CHAR belirtilen karakter kadar yeri mutlaka alır. Açıklaması şöyle
CHAR is fixed length while VARCHAR is variable length. That means, a CHAR(x) string has exactly x characters in length, including spaces. A VARCHAR(x) string can have up to x characters and it cuts off trailing spaces, thus might be shorter than the declared length.
CHAR Ne Zaman Kullanılır?
Eğer verinin uzunluğu sabitse ve 255'ten küçükse CHAR kullanılabilir.
Örnek
Şöyle yaparız
CREATE TABLE IF NOT EXISTS ADV.GSR_FUNCTIONPERMISSION
(
  ...
  REGISTRATIONALLOWED   CHAR(1)      DEFAULT 0 NOT NULL,

);
TEXT
Açıklaması şöyle.
A small non-binary string
Açıklaması şöyle. Yani TEXT tipi standart SQL tipi değil.
In SQL, there is no specific "text" column type. However, many SQL database systems provide data types that can store large amounts of textual data, such as "VARCHAR" or "TEXT" data types.

For example, MySQL provides a "TEXT" data type that can store up to 65,535 characters, while PostgreSQL provides a "VARCHAR" data type that can store up to 1 GB of textual data.

So while "text" is not a standard SQL column type, there are commonly used data types that can be used to store textual data in SQL databases.
TINYTEXT
Açıklaması şöyle.
A very small non-binary string
MEDIUMTEXT
Açıklaması şöyle.
A medium-sized non-binary string
LONGTEXT
A large non-binary string
Metin uzunlukları şöyle
      Type | Maximum length
-----------+-------------------------------------
  TINYTEXT |           255 (2 8−1) bytes
      TEXT |        65,535 (216−1) bytes = 64 KiB
MEDIUMTEXT |    16,777,215 (224−1) bytes = 16 MiB
  LONGTEXT | 4,294,967,295 (232−1) bytes =  4 GiB

Hiç yorum yok:

Yorum Gönder

Soft Delete

Giriş Açıklaması  şöyle When using the soft delete mechanism on the database, you might run into a situation where a record with a unique co...