mysql 1050,无法删除mySQL表。 (错误1050)

I have a pesky table that will not delete and it's holding up my dev environment refresh :(

I know this table exists. Example...

mysql> select * from uc_order_products_qty_vw limit 10;

+-----+-------------+---------+---------+---------+---------+

| nid | order_count | avg_qty | sum_qty | max_qty | min_qty |

+-----+-------------+---------+---------+---------+---------+

| 105 | 1 | 1.0000 | 1 | 1 | 1 |

| 110 | 5 | 1.0000 | 5 | 1 | 1 |

| 111 | 1 | 1.0000 | 1 | 1 | 1 |

| 113 | 5 | 1.0000 | 5 | 1 | 1 |

| 114 | 1 | 1.0000 | 1 | 1 | 1 |

| 115 | 1 | 1.0000 | 1 | 1 | 1 |

| 117 | 2 | 1.0000 | 2 | 1 | 1 |

| 119 | 3 | 1.3333 | 4 | 2 | 1 |

| 190 | 5 | 1.0000 | 5 | 1 | 1 |

| 199 | 2 | 1.0000 | 2 | 1 | 1 |

+-----+-------------+---------+---------+---------+---------+

10 rows in set (0.00 sec)

However when I try to drop it...

mysql> DROP TABLE IF EXISTS uc_order_products_qty_vw;

Query OK, 0 rows affected, 1 warning (0.00 sec)

It doesn't work, the table is still there, and the warning says this...

mysql> show warnings limit 1;

+-------+------+------------------------------------------+

| Level | Code | Message |

+-------+------+------------------------------------------+

| Note | 1051 | Unknown table 'uc_order_products_qty_vw' |

+-------+------+------------------------------------------+

1 row in set (0.00 sec)

Feeling pretty dumbfounded.

解决方案

Judging from the name it might be a view. Try using DROP VIEW:

DROP VIEW uc_order_products_qty_vw

DROP TABLE doesn't work for views:

CREATE VIEW test_vw AS SELECT 1;

SELECT * FROM test_vw; -- works

DROP TABLE test_vw; -- error: Unknown table 'test_vw'

DROP VIEW test_vw; -- works

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值