SQL DELETE Statement


The SQL DELETE Statement

The DELETE statement is used to delete existing records in a table.

DELETE Syntax

DELETE FROM table_name
WHERE condition;

Note: Be careful when deleting records in a table! Notice the WHERE clause in the DELETE statement. The WHERE clause specifies which record(s) that should be deleted. If you omit the WHERE clause, all records in the table will be deleted!


Demo Database

Below is a selection from the "Customers" table in the Northwind sample database:

CustomerID CustomerName ContactName Address City PostalCode Country
1

Alfreds Futterkiste Maria Anders Obere Str. 57 Berlin 12209 Germany
2 Ana Trujillo Emparedados y helados Ana Trujillo Avda. de la Constitución 2222 México D.F. 05021 Mexico
3 Antonio Moreno Taquería Antonio Moreno Mataderos 2312 México D.F. 05023 Mexico
4

Around the Horn Thomas Hardy 120 Hanover Sq. London WA1 1DP UK
5 Berglunds snabbköp Christina Berglund Berguvsvägen 8 Luleå S-958 22 Sweden

 

SQL DELETE Example

The following SQL statement deletes the customer "Alfreds Futterkiste" from the "Customers" table:

Example

DELETE FROM Customers
WHERE CustomerName='Alfreds Futterkiste';

The "Customers" table will now look like this:

CustomerID CustomerName ContactName Address City PostalCode Country
2 Ana Trujillo Emparedados y helados Ana Trujillo Avda. de la Constitución 2222 México D.F. 05021 Mexico
3 Antonio Moreno Taquería Antonio Moreno Mataderos 2312 México D.F. 05023 Mexico
4

Around the Horn Thomas Hardy 120 Hanover Sq. London WA1 1DP UK
5 Berglunds snabbköp Christina Berglund Berguvsvägen 8 Luleå S-958 22 Sweden

Delete All Records

It is possible to delete all rows in a table without deleting the table. This means that the table structure, attributes, and indexes will be intact:

DELETE FROM table_name;

or:

DELETE * FROM table_name;

Delete All Null Records

delete * from emp where comm is null;

delect *  from emp where comm='';

CREATE OR REPLACE PROCEDURE emp01_delete_null AS
BEGIN
DELETE FROM emp01 WHERE comm IS NULL;
COMMIT;
END emp01_delete_null; execute emp01_delete_null;

ORACLE_DELETE的更多相关文章

随机推荐

  1. 解决分批次调用 jsonp 接口的 callback 会报错问题

    当我们分批次调用同一个jsonp接口时,会有一定机率同时调用,而jsonp的callback不支持同时调用, 会报错,所以当我们在分批次调用同一jsonp接口时,最好在callback后加个变量值,总 ...

  2. BZOJ - 2005 莫比乌斯水题

    \(gcd=k+1\)时,每一个的贡献都是\(2k+1\) \(gcd=1\)时,每一个贡献为\(1\) #include<iostream> #include<algorithm& ...

  3. POJ - 3233 矩阵套矩阵

    题意:给你矩阵\(A\),求\(S=\sum_{i=1}^{k}A^i\) 构造矩阵 \[ \begin{bmatrix} A & E \\ 0 & E\\ \end{bmatrix} ...

  4. UVALive - 5963 ad-hoc

    注意到合法条件是对称的,那很有可能与2有关, 小于2表示没有这一页,大于2表示冲突了 我也不知道这样做对不对的(输入范围很迷),试一下就A了... #include<bits/stdc++.h& ...

  5. (转)Linux SSH批量分发管理

    Linux SSH批量分发管理 原文:http://blog.51cto.com/chenfage/1831166 第1章 SSH服务基础介绍 1.1 SSH服务 1.1.1SSH介绍 SSH是Sec ...

  6. Unity游戏项目常见性能问题

    Unity技术支持团队经常会对有需求的客户公司项目进行游戏项目性能审查与优化,在我们碰到过的各种项目相关的问题中也有很多比较共同的方面,这里我们罗列了一些常见的问题并进行了归类,开发者朋友们可以参考下 ...

  7. Nmap原理02 - 编写自己的服务探测脚本

    编写自己的服务探测脚本 1. 添加自己的探测脚本 nmap-service-probes文件的格式将在第二节介绍,本节通过一个例子说明如何添加自己的服务探测脚本. AMQP协议,即Advanced M ...

  8. 聚焦游戏安全,腾讯云GAME-TECH“空降”上海

    游戏行业是DDoS攻击高发行业,占DDoS攻击的六成以上,特别是近年来游戏行业的爆发式增长,游戏行业更成为了黑产.外挂.非法信息的聚集地.安全,已然成为游戏行业当前最大的敌人. 6月29日,腾讯云GA ...

  9. React.js 小书 Lesson13 - 渲染列表数据

    作者:胡子大哈 原文链接:http://huziketang.com/books/react/lesson13 转载请注明出处,保留原文链接和作者信息. 列表数据在前端非常常见,我们经常要处理这种类型 ...

  10. 深入理解JavaScript系列(28):设计模式之工厂模式

    介绍 与创建型模式类似,工厂模式创建对象(视为工厂里的产品)时无需指定创建对象的具体类. 工厂模式定义一个用于创建对象的接口,这个接口由子类决定实例化哪一个类.该模式使一个类的实例化延迟到了子类.而子 ...