mysql - MySql 查询非空约束时出错

标签 mysql sql mariadb

我有一个名为 practice 的表其中存在 firstname 列,我正在尝试执行以下查询。

alter table practice alter firstname not null ;

我得到了这个语法:

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'varchar not null' at line 1

需要澄清语法错误。

最佳答案

在更改列时,您必须指定数据类型并使用Modify关键字才能设置空或非空参数

例如:

alter table practice modify firstname varchar(25) not null ;

关于mysql - MySql 查询非空约束时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48661958/

相关文章:

mysql - 在 MariaDB 中设置无限超时 GET_LOCK()

mysql - 将 MySQL 表从 Latin1 转换为 UTF8 时整理丢失的信息

java - Spring Data 在条目尚不存在时插入数据

php - MATCH AGAINST 的反义词是什么?

mysql - 使用 Select 在特定列上插入,然后在其他列上使用普通结构

php - 优化此 SQL 查询

mysql - 不计数的时间求和范围重叠两次

mysql - 如何将json字符串作为存储过程参数进行处理

php - 不限制 where 语句

mysql - MySQL 中的 while 循环与 if 语句