DELETE 中文man页面

系统
DELETE 从指明的表里删除满足 WHERE 子句的行。 如果 WHERE 子句不存在, 效果是删除表中所有行。结果是一个有效的空表。

NAME

DELETE - 删除一个表中的行

SYNOPSIS

DELETE FROM [ ONLY ] table [ WHERE condition ]

DESCRIPTION 描述

DELETE 从指明的表里删除满足 WHERE 子句的行。 如果 WHERE 子句不存在, 效果是删除表中所有行。结果是一个有效的空表。

Tip: 提示: TRUNCATE [truncate(7)] 是一个 PostgreSQL 扩展, 它提供一个更快的从表中删除所有行的机制。


 缺省时 DELETE 将删除所声明的表和所有它的子表的记录。 如果你希望只更新提到的表,你应该使用 ONLY 子句。


 要对表进行删除,你必须对它有 DELETE 权限,同样也必须有 SELECT 的权限,这样才能对符合 condition  的值进行读取操作。  

PARAMETERS 参数

table

 一个现存表的名字(可以有模式修饰)。
condition

 一个返回 boolean 类型值的值表达式,它判断哪些行需要被删除。

OUTPUTS 输出


 成功时,DELETE 命令返回形如

DELETE count


 的标签。 count 是被删除的行数。 如果 count 为 0,没有行匹配 condition (这个不认为是错误)。  

EXAMPLES 例子


 删除所有电影(films)但不删除音乐(musicals):

DELETE FROM films WHERE kind <> 'Musical';


 清空表 films:

DELETE FROM films;

#p#

NAME

DELETE - delete rows of a table

SYNOPSIS

DELETE FROM [ ONLY ] table [ WHERE condition ]

DESCRIPTION

DELETE deletes rows that satisfy the WHERE clause from the specified table. If the WHERE clause is absent, the effect is to delete all rows in the table. The result is a valid, but empty table.

Tip: TRUNCATE [truncate(7)] is a PostgreSQL extension which provides a faster mechanism to remove all rows from a table.

By default, DELETE will delete rows in the specified table and all its subtables. If you wish to only delete from the specific table mentioned, you must use the ONLY clause.

You must have the DELETE privilege on the table to delete from it, as well as the SELECT privilege for any table whose values are read in the condition.  

PARAMETERS

table
The name (optionally schema-qualified) of an existing table.
condition
A value expression that returns a value of type boolean that determines the rows which are to be deleted.

OUTPUTS

On successful completion, a DELETE command returns a command tag of the form

DELETE count

The count is the number of rows deleted. If count is 0, no rows matched the condition (this is not considered an error).  

EXAMPLES

Delete all films but musicals:

DELETE FROM films WHERE kind <> 'Musical';

Clear the table films:

DELETE FROM films;

责任编辑:韩亚珊 来源: CMPP.net
相关推荐

2011-08-15 10:21:09

man中文man

2011-08-24 16:48:36

man中文man

2011-08-11 16:11:49

at中文man

2011-08-25 10:21:56

man.conf中文man

2011-08-12 14:58:05

killall中文man

2011-07-15 16:58:36

ac中文man

2011-08-15 11:10:48

more中文man

2011-08-25 17:03:51

pclose中文man

2011-08-15 14:10:37

tar中文man

2011-08-16 10:42:30

rmmod中文man

2011-08-11 17:46:02

chmod中文man

2011-08-18 13:57:38

acct中文man

2011-08-23 17:49:36

zdump中文man

2011-08-15 15:10:49

wall中文man

2011-08-23 15:22:52

rootflags中文man

2011-08-23 15:06:03

quotastats中文man

2011-08-15 17:35:50

ar中文man

2011-08-25 09:07:16

suffixes中文man

2011-08-25 17:53:26

stdio中文man

2011-08-18 15:21:37

autofs中文man
点赞
收藏

51CTO技术栈公众号