If you set a SET column to an unsupported value, the value is ignored and a warning is issued : Set : Data Types MySQL TUTORIALS


MySQL TUTORIALS » Data Types » Set »

 

If you set a SET column to an unsupported value, the value is ignored and a warning is issued


mysql>
mysql> CREATE TABLE myset (col SET('a''b''c''d'));
Query OK, rows affected (0.03 sec)

mysql> INSERT INTO myset (colVALUES ('a,d'),
    ->                                ('d,a'),
    ->                                ('a,d,a'),
    ->                                ('a,d,d'),
    ->                                ('d,a,d');
Query OK, rows affected (0.00 sec)
Records: 5  Duplicates: 0  Warnings: 0

mysql>
mysql> SELECT col FROM myset;
+------+
| col  |
+------+
| a,d  |
| a,d  |
| a,d  |
| a,d  |
| a,d  |
+------+
rows in set (0.00 sec)

mysql>
mysql> INSERT INTO myset (colVALUES ('a,d,d,s');
Query OK, row affected, warning (0.00 sec)

mysql>
mysql> SHOW WARNINGS;
+---------+------+------------------------------------------+
| Level   | Code | Message                                  |
+---------+------+------------------------------------------+
| Warning | 1265 | Data truncated for column 'col' at row |
+---------+------+------------------------------------------+
row in set (0.00 sec)

mysql>
mysql> SELECT col FROM myset;
+------+
| col  |
+------+
| a,d  |
| a,d  |
| a,d  |
| a,d  |
| a,d  |
| a,d  |
+------+
rows in set (0.00 sec)

mysql>
mysql>
mysql> drop table myset;
Query OK, rows affected (0.00 sec)

mysql>



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

MySQL TUTORIALS

 Navioo Data Types
» Set