Create a table with TEXT type column : Text Type « Data Type « SQL / MySQL






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)

   
    
    
    
    
  








Related examples in the same category

1. TEXT and BLOB Data Type Sizes and Upper Limits (in Bytes)
2.TEXT character string with variable length, maximum 2^16-1 characters