我需要加場像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) ' –