有哪些有用的SQL语句/使用模式应该被所有可能接触项目后端的开发人员所了解?[英] What are some useful SQL statements / usage patterns that should be known by all developers who may touch the Back end side of the project?

本文是小编为大家收集整理的关于有哪些有用的SQL语句/使用模式应该被所有可能接触项目后端的开发人员所了解?的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

所有可能触及项目后端的开发人员应该知道哪些有用的SQL语句?

(更新:就像算法一样,我们知道存在分类问题,调整问题,我们知道了一些解决方案.

例如,我能想到的是:

获取一个没有的类列表 由任何学生注册. (外 加入并检查比赛是否是 null,或从类表中获取 所有不在 子查询以获取所有分类 注册表))

是否应该在所有开发人员的袖子下进行一些SQL语句?

推荐答案

hmm概括您应该能够编写哪些类型的查询.

  1. 首先是直接选择
    加入(没有选择 *)
  2. 您应该知道如何结合两个 或更多表格,并获取记录 在所有表中
  3. 您应该知道如何结合两个 或更多表格,并获取记录 在所有桌子中,但返回 只有一张记录与桌子的记录 一对一的许多方面 关系
  4. 您应该能够获得 一张桌子中的记录,但没有 关联表
  5. 您应该能够汇总数据 报告
  6. 您应该能够插入一个 记录到表
  7. 您应该能够更新一个 在表中记录
  8. 您应该能够删除一个 在表中记录
  9. 您应该能够插入一个组 记录到没有一个的桌子 光标
  10. 您应该能够更新 没有表格中的记录 光标
  11. 您应该能够删除 没有表格中的记录 光标
  12. 您应该能够表演 一项交易中的多个操作 并处理错误陷阱
  13. 您应该能够创建联盟 记录并知道何时使用 联盟副联盟全部
  14. 您应该能够改变数据 对于一个基于某些字段 标准(使用案例)
  15. 您应该能够写一个 语句.

好吧,这就是立即浮现的.这当然是针对初学者SQL开发人员的.这不包括我会考虑高级.

其他推荐答案

开发人员应学习数据库和SQL的原理.没有任何特定的SQL语句,因为所需的SQL语句将根据数据库存储和数据库的结构而更改.

更新:您的更新问题很有趣.我认为SQL语句通常非常简单.因此,他们不值得记忆.如果它们很复杂,那么它们与特定问题有关,并且不值得记忆.

本文地址:https://www.itbaoku.cn/post/597765.html

问题描述

What are some useful SQL statements that should be known by all developers who may touch the Back end side of the project?

(Update: just like in algorithm, we know there are sorting problems, shuffling problems, and we know some solutions to them. This question is aiming at the same thing).

For example, one I can think of are:

Get a list of Classes that are not registered by any students. (Outer join and check whether the match is NULL, or by Get from Classes table, all ClassIDs which are NOT IN (a subquery to get all ClassIDs from the Registrations table))

Are there some SQL statements that should be under the sleeve of all developers that might touch back end data?

推荐答案

Hmm generalizing what types of queries you should be able to write.

  1. First a straight up select with no
    joins (and no select *)
  2. You should know how to combine two or more tables and get records that are in all the tables
  3. You should know how to combine two or more tables and get records that are in all the tables but return only one record from the table with the many side of the one-to-many relationship
  4. You should be able to get the records in one table but not in an associated table
  5. You should be able to Aggregate data for a report
  6. You should be able to insert one record to a table
  7. You should be able to update one record in a table
  8. You should be able to delete one record in a table
  9. You should be able to insert a group of records to a table without a cursor
  10. You should be able to update a group of records in a table without a cursor
  11. You should be able to delete a group of records in a table without a cursor
  12. You should be able to perform multiple actions in one transaction and handle error trapping
  13. You should be able to create union of records and know when to use UNION vice UNION ALL
  14. You should be able to vary the data for one field based on some criteria (using CASE)
  15. You should be able to write an IF Statement.

Well that's what springs to mind immedaitely. This is for a beginner SQL developer of course. This includes nothing I would consider advanced.

其他推荐答案

Developers should learn the principles of databases and SQL. Not any specific SQL statements as SQL statements required will change depending on what the database stores and the structure of the database.

Update: Your updated question is interesting. I am thinking SQL statements in general are quite simple. So they are not worth memorising. If they are complex then they are tied to a specific problem and again are not worth memorising.