Home Database Mysql Tutorial SQL DML与CTE解释

SQL DML与CTE解释

Jun 07, 2016 pm 05:43 PM
explain

DML (Data Manipulation Language) 与 CTE ( Common Table Expression ) 今天看书时遇到的两个缩写,不知道其含义,于是就百度了一下,特地在此记录下来,以便于下次复习使用。 关于DML (Data Manipulation Language): 数据操纵语言,用户能够查询数据库以

DML (Data Manipulation Language) 与 CTE (Common Table Expression)

  今天看书时遇到的两个缩写,网站空间,不知道其含义,于是就百度了一下,特地在此记录下来,以便于下次复习使用。

  关于DML (Data Manipulation Language):

    数据操纵语言,用户能够查询数据库以及操作已有数据库中的数据的计算机语言。具体是指是UPDATE更新、INSERT插入、DELETE删除

  关于CTE (Common Table Expression):

    CTE(Common Table Expression) ,即公用表表达式,可以认为是在单个 SELECT、INSERT、UPDATE、DELETE 或 CREATE ⅥEW 语句的执行范围内定义的临时结果集。CTE与派生表类似,具体表现在不存储为对象,并且只在查询期间有效。与派生表的不同之处在于,CTE 可自引用,还可在同一查询中引用多次。

  CTE可用于:

  • 创建递归查询(我个人认为CTE最好用的地方)。
  • 在同一语句中多次引用生成的表。
  •   CTE优点:

  • 使用 CTE 可以获得提高可读性和轻松维护复杂查询的优点。
  • 查询可以分为单独块、简单块、逻辑生成块。之后,香港虚拟主机,这些简单块可用于生成更复杂的临时 CTE,香港服务器,直到生成最终结果集。
  •   CTE可使用的范围:

      可以在用户定义的例程(如函数、存储过程、触发器或视图)中定义 CTE。

     

      下面看一个简单的CTE例题:

      把test表中salary最大的id记录保存在test_CTE中,再调用

      复制代码代码如下:

      with test_CTE(id,salary)   as   (     select id,max(salary)     from test     group by id    )   test_cte

     

    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

    Hot AI Tools

    Undresser.AI Undress

    Undresser.AI Undress

    AI-powered app for creating realistic nude photos

    AI Clothes Remover

    AI Clothes Remover

    Online AI tool for removing clothes from photos.

    Undress AI Tool

    Undress AI Tool

    Undress images for free

    Clothoff.io

    Clothoff.io

    AI clothes remover

    AI Hentai Generator

    AI Hentai Generator

    Generate AI Hentai for free.

    Hot Article

    R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
    4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
    R.E.P.O. Best Graphic Settings
    4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
    R.E.P.O. How to Fix Audio if You Can't Hear Anyone
    4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
    R.E.P.O. Chat Commands and How to Use Them
    4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

    Hot Tools

    Notepad++7.3.1

    Notepad++7.3.1

    Easy-to-use and free code editor

    SublimeText3 Chinese version

    SublimeText3 Chinese version

    Chinese version, very easy to use

    Zend Studio 13.0.1

    Zend Studio 13.0.1

    Powerful PHP integrated development environment

    Dreamweaver CS6

    Dreamweaver CS6

    Visual web development tools

    SublimeText3 Mac version

    SublimeText3 Mac version

    God-level code editing software (SublimeText3)

    What is the analysis of 2.8k screen? What is the analysis of 2.8k screen? Jan 02, 2024 pm 12:21 PM

    We often see the introduction of how many K screens we have when buying TVs, computers or mobile phones, such as 2.8K screens. At this time, there will be friends who don’t know much about electronic devices and will be curious about what this 2.8K screen means and what the resolution is. What does 2.8k screen mean? Answer: 2.8k screen means that the screen resolution is 2880*18002K, which means the number of horizontal pixels is greater than 2000. For the same size screen, the higher the resolution, the better the picture quality. Introduction to resolution 1. Since the points, lines and surfaces on the screen are all composed of pixels, the more pixels the monitor can display, the finer the picture, and the more information can be displayed in the same screen area. 2. The higher the resolution, the greater the number of pixels, and the sharper the sensed image.

    Use the typedef keyword in C language to interpret structures Use the typedef keyword in C language to interpret structures Aug 25, 2023 pm 01:25 PM

    Typedef 'C' allows new data type names to be defined using the 'typedef' keyword. Using ‘typedef’ we cannot create a new data type, but define a new name for an already existing type. The Chinese translation of Syntaxtypedefdatatypenewname;Example is: example typedefintbhanu;inta;bhanua;%dThisstatementtellsthecompilertorec

    What exactly is PHP SDK? What exactly is PHP SDK? Mar 11, 2024 am 11:24 AM

    PHPSDK is a software development toolkit used to assist developers to quickly and easily integrate third-party services or API interfaces in the PHP language. The full name of SDK is Software Development Kit, which is software development kit. It provides a series of functions, classes, methods and tools to make it easier for developers to interact with external services. In PHP development, SDK usually contains encapsulation of specific services to simplify the process of developers writing related code. PHPSD

    A deep dive into the practical uses of multi-line comments in PyCharm A deep dive into the practical uses of multi-line comments in PyCharm Feb 24, 2024 pm 06:03 PM

    Multi-line comments are a very useful tool in programming, which can help programmers better organize and comment code, improving the readability and maintainability of the code. In an integrated development environment like PyCharm, the use of multi-line comments is also very convenient. This article will introduce in detail the application scenarios of multi-line comments in PyCharm, as well as specific code examples. 1. Basic syntax of multi-line comments In Python, multi-line comments use three single quotes (''') or three double quotes (""") to wrap multi-line text. For example

    Learn more about the meaning and application areas of HTTP status code 80 Learn more about the meaning and application areas of HTTP status code 80 Feb 25, 2024 pm 04:42 PM

    Explore the explanation and usage scenarios of HTTP status code 80. HTTP status code is a status identifier used by the web server to provide request results to the client. The 80 status code refers to a permanent redirection. In this article, we will explain the meaning of HTTP status code 80 and explore its real-life usage scenarios. First, HTTP status code 80 indicates a permanent redirect. When the web server receives the client's request, if the resource has been moved to a new URL, the server will notify it by sending status code 80

    The role and explanation of eol in PHP The role and explanation of eol in PHP Mar 20, 2024 am 08:00 AM

    In PHP, eol refers to the newline character (endofline), a special character used in files to indicate the end of a text line. In different operating systems, the newline character may be represented differently. For example, in Unix/Linux systems, the newline character is "", and in Windows systems, the newline character is "". In PHP, eol is mainly used to control line wrapping format in text output. When we want to insert a newline character in a string, we can use eol to achieve this. For example, in the output HTML code, I

    Why does the CSS framework require JS support? Why does the CSS framework require JS support? Jan 03, 2024 pm 09:08 PM

    Title: Reasons why the CSS framework cannot be separated from the support of JS and analysis of code examples Abstract: This article will explain to readers why the CSS framework cannot be separated from the support of JavaScript and provide specific code examples for analysis. The combination of CSS framework and JavaScript brings more interactivity and dynamic effects to web design, providing users with a better experience. 1. Basic introduction to CSS framework CSS framework is a front-end development tool based on CSS (Cascading Style Sheets), which is used to simplify and accelerate web pages.

    Parsing HTTP status code 100: what does it mean? Parsing HTTP status code 100: what does it mean? Feb 18, 2024 pm 07:42 PM

    HTTP status code 100 explained: What does it mean? HTTP status code is a common message status indication method in Internet communications. It is used to identify the request status and server response status. Among them, status code 100 is one of the request status codes. Its meaning is to indicate that the server has understood the client's request and the request can continue. In the HTTP protocol, each status code has its specific meaning and purpose. Status code 100 is an intermediate status code that is typically used when a client sends a request to the server. when

    See all articles