网上找到好多 获取字段的默认值 但是感觉很复杂 还报错 最后找到一个 就一句 真不知道那些复杂的是做什么用的。。
获取默认值我已经知道了
show columns from `表明` where Field='字段名' 获取字段的设置信息
想知道 怎么修改默认值 网上找到的是这个
alter table tablename alter column drop default; (若本身存在默认值,则先删除)alter table tablename alter column set default 't5';(若本身不存在则可以直接设定)但是一直提示错误
求教!!
获取默认值我已经知道了
show columns from `表明` where Field='字段名' 获取字段的设置信息
想知道 怎么修改默认值 网上找到的是这个
alter table tablename alter column drop default; (若本身存在默认值,则先删除)alter table tablename alter column set default 't5';(若本身不存在则可以直接设定)但是一直提示错误
求教!!
我想修改 aaaa表中的 bbbb字段的 默认值 为cccc
语句是什么样的呢?
Query OK, 0 rows affected (0.05 sec)mysql> desc x;
+-------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| id | int(11) | YES | | NULL | |
| f | int(11) | YES | | 5 | |
+-------+---------+------+-----+---------+-------+
2 rows in set (0.02 sec)mysql> alter table x modify f int default 3;
Query OK, 0 rows affected (0.06 sec)
Records: 0 Duplicates: 0 Warnings: 0mysql> desc x;
+-------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| id | int(11) | YES | | NULL | |
| f | int(11) | YES | | 3 | |
+-------+---------+------+-----+---------+-------+
2 rows in set (0.02 sec)mysql>
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'not null default 666' at line 1