我需要加场像MySql的数组类型和默认值
`setting_notification` = 'a:2:{s:19:"other_notifications";i:1;s:21:"message_notifications";i:0;}'
ALTER TABLE app_users ADD setting_notification tinytext COLLATE utf8_unicode_ci NOT NULL COMMENT '(DC2Type:array)'
默认值怎么能这样做?
我试试这个
ALTER TABLE app_users
ADD setting_notification LONGTEXT CHARACTER SET utf8
DEFAULT 'a:2:{s:19:"other_notifications";i:1;s:21:"message_notifications";i:0;}'
COMMENT '(DC2Type:array)'
而且有错误
[Err] 1101 - BLOB, TEXT, GEOMETRY or JSON column 'setting_notification' can't have a default value
,并尝试像
ALTER TABLE app_users
ADD setting_notification tinytext
DEFAULT "a:2:{s:19:\"other_notifications\";i:1;s:21:\"message_notifications\";i:0;}"
COLLATE utf8_unicode_ci
NOT NULL COMMENT '(DC2Type:array)'
仍然有错误
[Err] 1101 - BLOB, TEXT, GEOMETRY or JSON column 'setting_notification' can't have a default value
sql版本
mysql> SELECT VERSION();
+-------------------------+
| VERSION() |
+-------------------------+
| 5.7.16-0ubuntu0.16.04.1 |
+-------------------------+
1 row in set (0,01 sec)
什么是mysql版本? – Alex
'mysql> SELECT VERSION(); + ------------------------- + | VERSION()| + ------------------------- + | 5.7.16-0ubuntu0.16.04.1 | + ------------------------- + set in set(0,01 sec) ' –