Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
Which MySQL Datatype should be used for storing BloodType?
To store BloodType, use varchar(3) or ENUM. Let us first create a table −
mysql> create table DemoTable1855 ( BloodType varchar(3) ); Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1855 values('A+');
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1855 values('A-');
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1855 values('B+');
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1855 values('B-');
Query OK, 1 row affected (0.00 sec)
mysql> insert into DemoTable1855 values('AB+');
Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1855;
This will produce the following output −
+-----------+ | BloodType | +-----------+ | A+ | | A- | | B+ | | B- | | AB+ | +-----------+ 5 rows in set (0.00 sec)
Advertisements
