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-24 16:48:36

man中文man

2011-08-15 10:21:09

man中文man

2011-08-11 16:11:49

at中文man

2011-08-25 10:21:56

man.conf中文man

2011-08-11 15:03:21

ACCESS中文man

2011-08-16 10:59:16

pwconv中文man

2011-08-18 19:02:43

environ中文man

2011-08-25 17:43:07

snprintf中文man

2011-08-19 18:30:52

ipc中文man

2011-08-25 17:18:07

putc中文man

2011-08-15 13:53:19

stat中文man

2011-08-25 15:24:31

execlp中文man

2011-08-15 18:06:07

restore中文man

2011-08-24 17:26:35

reindex中文man

2011-08-15 15:45:04

xpdf中文man

2011-08-24 17:06:42

NOTIFY中文man

2011-08-15 14:42:28

uname中文man

2011-08-15 11:30:37

pwd中文man

2011-08-23 14:24:42

ping中文man

2011-08-15 11:01:45

点赞
收藏

51CTO技术栈公众号