【问题标题】:How can we drop multiple columns in MariaDB in one command我们如何在一个命令中删除 MariaDB 中的多个列
【发布时间】:2020-06-25 04:44:39
【问题描述】:

我试图在一个命令中删除多个列。 我尝试过以下命令:

ALTER TABLE table DROP COLUMN col1, col2;

ALTER TABLE 表 DROP COLUMN (col1, col2);

ALTER TABLE table DROP COLUMN col1, col2;

ALTER TABLE 表 DROP COLUMN "col1", "col2";

ALTER TABLE table DROP COLUMNS col1, col2;

P.S:以上方法均无效。

【问题讨论】:

    标签: mariadb alter mariasql


    【解决方案1】:

    Read the fine manual:

    ALTER TABLE tbl_name alter_specification [, alter_specification]

    例如

    MariaDB [test]> create table t1 (a int, b int, c int);
    Query OK, 0 rows affected (0.03 sec)
    
    MariaDB [test]> alter table t1 drop column a, drop column b;
    Query OK, 0 rows affected (0.01 sec)
    Records: 0  Duplicates: 0  Warnings: 0
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-20
      • 2012-12-31
      • 2023-03-31
      • 2018-04-09
      • 2021-03-25
      • 1970-01-01
      • 1970-01-01
      • 2015-02-24
      相关资源
      最近更新 更多