Boolean hauv MySQL yog dab tsi?
Boolean hauv MySQL yog dab tsi?

Video: Boolean hauv MySQL yog dab tsi?

Video: Boolean hauv MySQL yog dab tsi?
Video: qhia sau program muag khoom hauv vb net nrog rau database sql server daim 9 frmOrderProduct 2024, Kaum ib hlis
Anonim

Kom nws yooj yim dua, MySQL muab BOOLEAN los yog BOOL raws li lub ntsiab lus ntawm TINYINT(1). Hauv MySQL , xoom yog suav tias yog cuav, thiab tsis yog xoom tus nqi yog suav tias yog qhov tseeb. Siv Boolean literals, koj siv cov constants TRUE thiab FALSE uas ntsuas rau 1 thiab 0 feem.

Tom qab ntawd, ib tus tuaj yeem nug, dab tsi yog Boolean cov ntaub ntawv hauv MySQL?

Bool , Boolean : Cov hom TINYINT (1). Tus nqi ntawm xoom yog suav tias yog cuav. Non-zero qhov tseem ceeb suav hais tias muaj tseeb. MySQL kuj hais tias: Peb npaj siab yuav ua kom tiav hom boolean tuav, inaccordance nrog tus qauv SQL, yav tom ntej MySQL tso tawm.

Qhov thib ob, yog Tinyint yog Boolean? 5 Teb. MySQL tsis muaj nyob hauv boolean hom ntaub ntawv. Nws siv tus lej tsawg tshaj plaws cov ntaub ntawv hom - TINYINT . Qhov BOOLEAN thiab BOOL yog sib npaug ntawm TINYINT (1), vim lawv yog cov lus.

Tom qab ntawd, lo lus nug yog, dab tsi yog Boolean hauv database?

Boolean cov neeg ua haujlwm tsim lub hauv paus ntawm cov lej lej thiab database logic. Lawv txuas koj cov lus tshawb fawb ua ke kom nqaim lossis nthuav koj cov txiaj ntsig. Peb lub hauv paus boolean Cov neeg ua haujlwm yog: THIAB, LOSSIS, thiab TSIS TAU.

Tinyint 1 txhais li cas?

TINYINT Hom ntaub ntawv. A 1 -byte integer datatype siv hauv CREATE TABLE thiab ALTER TABLE nqe lus. Impalareturns tus nqi loj tshaj plaws los yog tsawg tshaj plaws nyob rau hauv ntau yam rau hom. Piv txwv li, qhov tseem ceeb siv tau rau a txii Qhov nruab nrab ntawm -128 mus rau 127. Hauv Impala, a txii nrog tus nqi ntawm -200 rov qab -128 dua li NULL.

Pom zoo: