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. [转] Jenkins Pipeline插件十大最佳实践

    [From] http://blog.didispace.com/jenkins-pipeline-top-10-action/ Jenkins Pipeline 插件对于 Jenkins 用户来说可 ...

  2. [转] 如何批量删除Docker中已经停止的容器

    [From]https://blog.csdn.net/csdn_duomaomao/article/details/78587103 方法一: #显示所有的容器,过滤出Exited状态的容器,取出这 ...

  3. 公钥,私钥,数字签名,SSL的基本概念

    一,公钥私钥 1,公钥和私钥成对出现 2,公开的密钥叫公钥,只有自己知道的叫私钥 3,用公钥加密的数据只有对应的私钥可以 解密 4,用私钥加密的数据只有对应的公钥可以解密 5,如果可以用公钥解密,则必 ...

  4. pg存储过程和sql语句块

    展E宝项目使用的是postgresql数据库,批量发送红包需求,需要采用存储过程来初始化红包记录数据. 创建存储过程语句有固定的架子,如下 CREATE OR REPLACE FUNCTION pub ...

  5. web安全——文件上传

    文件上传本身不是漏洞,但如果文件上传功能的限制出现纰漏,允许了不合法且影响网站安全的文件的上传    可以将不合法且影响网站安全稳定性的文件等内容上传的均为“文件上传漏洞”        黑方将文件上 ...

  6. Oracle RAC集群搭建(六)--ASM创建oradata的磁盘组

    一,查看实例环境 su - grid env|grep ORA 发现连接空实例 改环境 到这里检测就完成了 二,配置安装 grid 用户输入asmca ASM数据盘就创建好了      

  7. Maths Intro - Probability

    设事件A,B,C两辆独立,且满足ABC=空集,及P(A)=P(B)=P(C)=x,求max(x) x最大值为1/2分析: x值要保证所有的由A.B.C交或并得到的集合的概率测度在0到1之间. 先考虑A ...

  8. 1、java线程模型

    要了解多线程,先需要把java线程模型搞清楚,否则有时候很难理清楚一个问题. 硬件多线程: 物理机硬件的并发问题跟jvm中的情况有不少相似之处,物理机的并发处理方案对于虚拟机也有相当大的参考意义.在买 ...

  9. 我的博客已经迁移到csdn

    博客已经迁移csdnhttp://blog.csdn.net/u013372900 博客园我很喜欢是源于他的可扩展性,可以自己去改,但遗憾的是博客园的速度似乎不是很给力.IT能有今天的 发展是源于无数 ...

  10. Notepad++的ftp远程编辑功能

    我们主要来说说NppFTP的使用方法: 1.启动notepad++后,点击插件-->NppFTP-->Show NppFTP Window,就可以显示NppFTP的管理窗口了. 2.在Np ...