문제

What is the best data type to store boolean values in a database? which is supported by mostly used RDBMS types such as Mysql,oracle,postgres,mssql

도움이 되었습니까?

해결책

you can use TINYINT or bit datatype

다른 팁

If the DBMS supports a real boolean type (e.g. PostgreSQL) then use that. If it doesn't I usually prefer an integer value combined with a check constraint that ensures that only 0 and 1 can be stored. In my experience it also makes sense to define the column as NOT NULL as well. Having a NULL value for a boolean is always somewhat confusing.

You won't find a single datatype that works for all DBMS. I would always use the "best" one that the DBMS offers.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top