【发布时间】:2016-03-21 18:40:31
【问题描述】:
我正在尝试使用postgres,但无法让这个简单的查询工作:
drop table mytable if (select count(*) from mytable)<50 ;
这给出了错误:
ERROR: syntax error at or near "if"
LINE 1: drop table tablename if (select count(*) from mytable)<50 ;
在给定条件下如何更改/删除 postgres 中的表?
【问题讨论】:
-
Postgres 不支持
DROP TABLE上的WHERE或IF子句:postgresql.org/docs/current/static/sql-droptable.html。 -
为什么要这样做?但要回答您的问题,请将
drop放在if之后。在互联网上询问陌生人之前,请先阅读文档。
标签: sql postgresql postgresql-9.4 drop-table