dpcj40970 2017-06-06 19:28
浏览 38

laravel中的SQL错误

I am trying to change a field in my users table to a varchar of 200. Currently it is 60 and not long enough. I tried using ->change() but because the table has an enum I get an error Unknown database type enum requested, Doctrine\DBAL\Platforms\MySQL57Platform may not support it. As a result I am trying to change the column using a raw sql statement. Here is the line I am trying to use.

DB::statement('ALTER TABLE users CHANGE COLUMN subrole VARCHAR(200)');

When I try this I get an error

[Illuminate\Database\QueryException]                                                                                                                                   
  SQLSTATE[42000]: Syntax error or access violation: 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 'VARCHAR(200)' at line 1 (SQL: ALTER TABLE users CHANGE COLUMN subrole VARCHAR(200))

What do I need to change? I am trying to change the column of subrole to size varchar 200.

  • 写回答

2条回答 默认 最新

  • dongzhabo2796 2017-06-06 19:31
    关注

    could be you need MODIFY

     DB::statement('ALTER TABLE users MODIFY COLUMN subrole VARCHAR(200)');
    
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度