fosstodon.org is one of the many independent Mastodon servers you can use to participate in the fediverse.
Fosstodon is an invite only Mastodon instance that is open to those who are interested in technology; particularly free & open source software. If you wish to join, contact us for an invite.

Administered by:

Server stats:

9.8K
active users

#SQL

63 posts57 participants8 posts today

This FirebirdSQL pull request introduces SQL-compliant aliases GREATEST and LEAST for the existing MAXVALUE and MINVALUE functions. These aliases align with the SQL:2023 standard and provide a more intuitive and widely recognized syntax. The changes include updates to documentation, keywords, parser tokens, and system function definitions to support these new aliases.

github.com/FirebirdSQL/firebir

Adding SQL-compliant names to existing MAXVALUE/MINVALUE functions
GREATEST and LEAST are reserved words.
<greatest or least function> ::=
    <greatest or least> <left paren> &lt...
GitHubGREATEST and LEAST (SQL:2023 - T054) by ChudaykinAlex · Pull Request #8532 · FirebirdSQL/firebirdBy ChudaykinAlex
Continued thread
root@1a7a2121da08:/llm/ollama# ./ollama run ReikaAssistant "How can I delete entries on SQL using commands?" --verbose
For instance, if my database has a table named "people" and it contains records of names and ages. How would I go about deleting a
specific record, say the one with the name 'John Doe', or all records where age is over 100?
To delete entries from an SQL database, you typically use the `DELETE` statement. Here are some common ways to delete records based
on your criteria:

### Deleting Specific Records

If you want to delete a specific record from the "people" table, say for example, the one with the name 'John Doe', you would do
something like this:

```sql
DELETE FROM people WHERE name = 'John Doe';
```

This command deletes all records where `name` is equal to 'John Doe'.

**Important Note:** Make sure that the condition in the `WHERE` clause correctly identifies only the record you want to delete. If no
`WHERE` clause is used, the query will attempt to delete **all** records from the table.

### Deleting Multiple Records

If you need to remove all records where a certain condition is met, such as deleting all people over 100 years old, you can use:

```sql
DELETE FROM people WHERE age > 100;
```

This will delete every record in the "people" table where `age` is greater than 100.

### Deleting All Records

If your goal is to clear out all records from a particular table (essentially truncating it), you can use:

```sql
TRUNCATE TABLE people;
```

Or, equivalently using the `DELETE` statement with no `WHERE` clause:

```sql
DELETE FROM people;
```

Both of these will remove **all** rows from the "people" table.

### Important Considerations

- **Backup Your Data:** Always make sure to back up your data before performing delete operations.
- **Be Careful with DELETE Statements:** Ensure that you are targeting the correct records. Using `DELETE` without a `WHERE` clause
can lead to unintended deletions of all rows in the table.

### Example Use Case

Let's assume you have the following schema for the "people" table:

```sql
CREATE TABLE people (
id INT PRIMARY KEY,
name VARCHAR(100),
age INT
);
```

And some sample data:

| id | name | age |
|----|---------------|-----|
| 1 | John Doe | 25 |
| 2 | Jane Smith | 30 |
| 3 | Michael Brown| 75 |
| 4 | Alice Johnson |110 |

To delete all people over the age of 100:

```sql
DELETE FROM people WHERE age > 100;
```

This would leave you with:

| id | name | age |
|----|---------------|-----|
| 1 | John Doe | 25 |
| 2 | Jane Smith | 30 |
| 3 | Michael Brown| 75 |

Alternatively, to delete a specific person named 'John Doe':

```sql
DELETE FROM people WHERE name = 'John Doe';
```

Result:

| id | name | age |
|----|---------------|-----|
| 2 | Jane Smith | 30 |
| 3 | Michael Brown| 75 |

### Conclusion

The `DELETE` statement is powerful and can be used to manage your database records efficiently. Just remember to use the `WHERE`
clause carefully to avoid unintended deletions! 🚨🚨🚨

---

**Additional Resources:**

- [SQL DELETE Statement](https://www.w3schools.com/sql/sql_delete.asp)
- [Truncate Table vs Delete](https://www.geeksforgeeks.org/truncate-vs-delete-in-sql/) - A comparison between `TRUNCATE` and `DELETE`. 🚀🚀🚀

---

**Remember:** Always double-check your queries to ensure they're doing exactly what you intend! 💡💡💡

---

**Community Tips:**

- **Use Caution with `DELETE`:** It's powerful but can cause data loss. Double-check the conditions before executing.
- **Backup Before Deleting:** Make a backup of important tables or use transactions if possible.

Happy querying! 🍊💪👨‍💻👩‍💻

---

**Tagging:**

#SQL #DeleteStatement #DatabaseManagement #ProgrammingTips #DataIntegrity #BackupsAreKey #CarefulWithDeletes #SQLQueries #TruncateTables #RecordDeletion #DataManipulationLanguage (DML)
#ComputerScience #TechTips 🌐💡✍️💻📊📈💪

---

**Feedback:**

Is there anything you'd like to add or any questions about deleting records in SQL? Share your thoughts below! 💬📖📝💬👩‍🏫👨‍🏫🎓🔍🔎📚📖📝💬👩‍🏫👨‍🏫🎓🔍🔎📚📖📝💬

---

**Related Articles:**

- [How to Use JOIN in SQL](https://www.example.com/join-in-sql) - Learn about joining tables for more complex queries.
- [Mastering Transactions in SQL](https://www.example.com/transactions-sql) - Understand how transactions can help manage your data.

---

**Community Contribution Request:**

If you have a specific use case or question related to deleting records, feel free to share it here! Let's learn together and improve our SQL skills. 🌟🌟🌟

---

📚 Антипаттерны SQL. Как избежать ловушек при работе с базами данных

Отличная книга. Содержит распространенные антипаттерны, объясняет не только, чем они плохи, но и когда допустимы и чем их заменить. Очень практичная и полезная.

Но меня смутило, что автору норм хранить изображения в самой БД 🙄

books.yandex.ru/books/wdQaqog2
#sql

Ok. Just culled ~20,000 of 25,000 #tumblr posts accumulated via #RSS over a month. I've gotta get to work on my own project applying basic statistics to this stuff. Think "reverse chronological + $all_your_own_filtering_and_sorting_and_bucketing". Not sure if I should do that within the confines of a #thunderbird add-on, or try some other approach. I really, really want to be able to use #sql for this stuff. It's a natural fit. But #sqlite seems to be a no-go for #WebExtensions. There is only #IndexedDB, which, in my limited experience with it, is absolute garbage to work with.