2.9. Deletions

|       2.9. Deletions       |                       |                           |                  |                               |
|:--------------------------:|-----------------------|---------------------------|------------------|-------------------------------|
|[Prev](tutorial-update.html)|[Up](tutorial-sql.html)|Chapter 2. The SQL Language|[Home](index.html)| [Next](tutorial-advanced.html)|

---

## 2.9. Deletions

[]()

 Rows can be removed from a table using the `DELETE` command. Suppose you are no longer interested in the weather of Hayward. Then you can do the following to delete those rows from the table:

```
DELETE FROM weather WHERE city = 'Hayward';

```

 All weather records belonging to Hayward are removed.

```
SELECT * FROM weather;

```

```
     city      | temp_lo | temp_hi | prcp |    date
---------------+---------+---------+------+------------
 San Francisco |      46 |      50 | 0.25 | 1994-11-27
 San Francisco |      41 |      55 |    0 | 1994-11-29
(2 rows)

```

 One should be wary of statements of the form

```
DELETE FROM tablename;

```

 Without a qualification, `DELETE` will remove *all* rows from the given table, leaving it empty. The system will not request confirmation before doing this!

---

|[Prev](tutorial-update.html)|[Up](tutorial-sql.html)| [Next](tutorial-advanced.html)|
|:---------------------------|:---------------------:|------------------------------:|
|        2.8. Updates        |  [Home](index.html)   |  Chapter 3. Advanced Features |

 // \<![CDATA[ \<-- For SVG support if ('WebSocket' in window) { (function() { function refreshCSS() { var sheets = [].slice.call(document.getElementsByTagName("link")); var head = document.getElementsByTagName("head")[0]; for (var i = 0; i \< sheets.length; ++i) { var elem = sheets[i]; head.removeChild(elem); var rel = elem.rel; if (elem.href && typeof rel != "string" || rel.length == 0 || rel.toLowerCase() == "stylesheet") { var url = elem.href.replace(/(&|\\?)\_cacheOverride=\\d+/, ''); elem.href = url + (url.indexOf('?') \>= 0 ? '&' : '?') + '\_cacheOverride=' + (new Date().valueOf()); } head.appendChild(elem); } } var protocol = window.location.protocol === 'http:' ? 'ws://' : 'wss://'; var address = protocol + window.location.host + window.location.pathname + '/ws'; var socket = new WebSocket(address); socket.onmessage = function(msg) { if (msg.data == 'reload') window.location.reload(); else if (msg.data == 'refreshcss') refreshCSS(); }; console.log('Live reload enabled.'); })(); } // ]]\>