Mega Code Archive

 
Categories / MySQL / Data Type
 

Create a table with TEXT type column

mysql> mysql> CREATE TABLE IF NOT EXISTS fruit     -> (     ->   id INT,     ->   name TEXT,     ->   color TEXT     -> ); Query OK, 0 rows affected (0.00 sec) mysql> mysql> # show that the table has been created mysql> SHOW TABLES; +----------------+ | Tables_in_test | +----------------+ | fruit          | | indexes        | | number_sets    | | time_table     | +----------------+ 4 rows in set (0.00 sec) mysql> mysql> # confirm the "fruit" table format mysql> EXPLAIN fruit; +-------+---------+------+-----+---------+-------+ | Field | Type    | Null | Key | Default | Extra | +-------+---------+------+-----+---------+-------+ | id    | int(11) | YES  |     | NULL    |       | | name  | text    | YES  |     | NULL    |       | | color | text    | YES  |     | NULL    |       | +-------+---------+------+-----+---------+-------+ 3 rows in set (0.00 sec) mysql> mysql> drop table fruit; Query OK, 0 rows affected (0.00 sec)