gpt4 book ai didi

mysql - 如何将列的类型从 varchar(30) 更改为 varchar(100)?

转载 作者:可可西里 更新时间:2023-11-01 06:34:41 30 4
gpt4 key购买 nike

我有一个这样描述的表:

mysql> describe easy_table;
+---------------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------------+--------------+------+-----+---------+----------------+
| id | bigint(20) | NO | PRI | NULL | auto_increment |
| version | bigint(20) | NO | | NULL | |
| account_id | bigint(20) | NO | MUL | NULL | |
| city | varchar(30) | NO | | NULL | |
...
| name | varchar(255) | YES | | NULL | |
| name_two | varchar(255) | YES | | NULL | |
+---------------------+--------------+------+-----+---------+----------------+
13 rows in set (0.03 sec)

我试图让城市 varchar 变大到 varchar(100),但这条线不起作用

alter table easy_table alter column city varchar(100);

这也行不通

alter table easy_table alter column city varchar(100) not null;

我收到这个错误:

ERROR 1064 (42000): 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 'varchar(100)' at line 1

最佳答案

alter table easy_table modify column city varchar(100) not null;

关于mysql - 如何将列的类型从 varchar(30) 更改为 varchar(100)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6133889/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com