mysql 1090_MySQL - error messages - Error: 1090 - You can't delete all columns with ALTER TABLE...

Discussion

This error message (shown in full below) arises from an ALTER TABLE operation in which you try to drop all of the columns in a table. As the error message says, you cannot remove all columns from a table using ALTER TABLE.

Error: 1090 - You can't delete all columns with ALTER TABLE; use DROP TABLE instead

SQLSTATE: 42000 (ER_CANT_REMOVE_ALL_FIELDS)

Below is a simple example of this error with a table containing only one column:

CREATE TABLE table1 (col1 char(1));

ALTER TABLE table1 DROP col1;

ERROR 1090 (42000): You can't delete all columns with ALTER TABLE;

use DROP TABLE instead

Trying to drop the last column, the only column results in error 1090. Similarly, if you have a table with multiple columns, and you try to remove them all with an ALTER TABLE, you will still get the same error:

CREATE TABLE table1 (col1 char(1), col2 char(1), col3 char(1));

ALTER TABLE table1 DROP COLUMN col1,

DROP COLUMN col2, DROP COLUMN col3;

ERROR 1090 (42000): You can't delete all columns with ALTER TABLE;

use DROP TABLE instead

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这个错误出现的原因是输入的数据源没有任何列信息,因此在生成目标数据表时无法确定列名和数据类型,导生成失败。解决方法是在输入数据源中指定列信息,或者在目标表中手动指定列名和数据类型。 如果你的输入数据源是 HDFS 上的文件,可以在 Sqoop 命令中使用 --columns 参数指定列信息,例如: ``` sqoop export --connect "jdbc:mysql://localhost:3306/zongheshiyan?useUnicode=true&characterEncoding=utf-8" --username root --password root --export-dir '/data/000000_0' --table ut_chenjiao --input-fields-terminated-by '\t' --driver com.mysql.jdbc.Driver --columns "col1,col2,col3" ``` 其中,"col1,col2,col3" 是你数据源中的列信息,需要根据实际情况进行修改。如果你的输入数据源是关系型数据库,可以在 Sqoop 命令中使用 --query 参数指定查询语句,并在查询语句中指定列信息,例如: ``` sqoop export --connect "jdbc:mysql://localhost:3306/zongheshiyan?useUnicode=true&characterEncoding=utf-8" --username root --password root --table ut_chenjiao --input-fields-terminated-by '\t' --driver com.mysql.jdbc.Driver --query "SELECT col1,col2,col3 FROM mytable WHERE \$CONDITIONS" ``` 其中,"SELECT col1,col2,col3 FROM mytable WHERE \$CONDITIONS" 是你的查询语句,需要根据实际情况进行修改。注意,在查询语句中要使用 "\$CONDITIONS" 占位符,Sqoop 会自动替换成分割数据的条件。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值