After mysql creates the table, modify the id attribute in the table to be empty by default

    Today I forgot to set the attribute that is empty by default in the creation of the database table, and because there are many table associations, it is difficult to delete the table and then create the table, you can only modify the table. The
specific code is as follows:
The default value is set to "" below, instead of null

ALTER TABLE users ALTER COLUMN id SET DEFAULT '';
alter table 表名 alter column 字段名 drop default; (若本身存在默认值,则先删除)

alter table 表名 alter column 字段名 set default 默认值;(若本身不存在则可以直接设定)

Guess you like

Origin blog.csdn.net/he1234555/article/details/114089057