博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
sql关键字_SQL关键字
阅读量:2530 次
发布时间:2019-05-11

本文共 9021 字,大约阅读时间需要 30 分钟。

sql关键字

SQL keywords are the reserved words for SQL operations. These Keywords are used across SQL version for different functionalities.

SQL关键字是SQL操作的保留字。 这些关键字在SQL版本中用于不同的功能。

SQL关键字 (SQL Keywords)

SQL Keywords
keywords are case insensitive. So the keyword SELECT and select will behave in the same way. Let’s look at some of the commonly used SQL keywords.

关键字不区分大小写。 因此,关键字SELECT和select的行为将相同。 让我们看一些常用SQL关键字。

  1. ALTER TABLE: ALTER TABLE is used for altering column of a table.
    ALTER TABLE table_name ADD column datatype;

    Output: On execution of this command a column will get added to the table table_name.

    ALTER TABLE :ALTER TABLE用于更改表的列。

    输出 :执行此命令时,将在表table_name中添加一列。

  2. AND: AND is an which is used for adding multiple condition. If the conditions are satisfied by a row. It will be part of the result set.
    SELECT column_nameFROM table_nameWHERE column1 = value1AND column2 = value2;

    Output: On execution of this command, if column1 is equal to value1 and column2 is equal to value2 then only the row will be qualified for result set.

    AND :AND是一个 ,用于添加多个条件。 如果条件连续满足。 它将成为结果集的一部分。

    输出 :执行此命令时,如果column1等于value1且column2等于value2,则仅该行符合条件集。

  3. AS: AS is used for aliasing a column or table.
    SELECT column_name AS 'Alias'FROM table_name;

    Output: On execution of this command, the result will display column_name as ‘Alias’.

    AS :AS用于别名列或表。

    输出 :执行此命令时,结果将显示column_name为'Alias'。

  1. AVG: AVG is an aggregate function which will provide the average of the numeric column.
    SELECT AVG(column_name) FROM table_name;

    Output: Execution of this command will provide the average of column_name.

    AVG :AVG是一个聚合函数,它将提供数字列的平均值。

    输出 :执行此命令将提供column_name的平均值。

  2. BETWEEN: BETWEEN is an operator which is used for defining a set. The value for range can be numeric, text and date.
    SELECT column_name(s)FROM table_nameWHERE column_name BETWEEN value1 AND value2;

    Output: Execution of this command will give a result set bounded by value1 and value2.

    BETWEEN :BETWEEN是用于定义集合的运算符。 范围的值可以是数字,文本和日期。

    输出 :执行此命令将给出一个以value1和value2为边界的结果集。

  3. COUNT: COUNT is a function which provides the count of the row for a column. The column should be a not null column.
    SELECT COUNT(column_name) FROM table_name;

    Output: On execution of this command, the result will contain the count of the rows for column_name.

    COUNT :COUNT是一项功能,可为列提供行数。 该列应为非空列。

    输出 :执行此命令时,结果将包含column_name的行数。

  4. CREATE TABLE: This command is used to create table in the database. It allows to specify the name of the table along with the name a datatype of the column.
    CREATE TABLE table_name (column1 datatype, column2 datatype);

    Output: Execution of this command will result in creation of table with name as table_name along with column1 and column2 as the columns of the table.

    CREATE TABLE :此命令用于在数据库中创建表。 它允许指定表的名称以及列的数据类型的名称。

    输出 :执行此命令将创建名称为table_name的表以及列1和列2作为表的列。

  5. DELETE: DELETE is the command which is used for removing rows from the table
    DELETE FROM table_name WHERE column_name = value;

    Output: On execution of this command the rows that will be selected based on the condition in the WHERE clause will be deleted.

    DELETE :DELETE是用于从表中删除行的命令

    输出 :执行此命令时,将根据WHERE子句中的条件选择的行将被删除。

  1. GROUP BY: GROUP BY is a clause in SQL that is only used with aggregate functions. It is used along with the SELECT statement to arrange identical data into groups.
    SELECT COUNT(*)FROM table_nameGROUP BY column_name;

    Output: Execution of this order will result in grouping the result set based on the column_name.

    GROUP BY :GROUP BY是SQL中的一个子句,仅与聚合函数一起使用。 它与SELECT语句一起使用,将相同的数据分为几组。

    输出 :执行此命令将导致根据column_name对结果集进行分组。

  2. INNER JOIN: INNER JOIN will select records with matching values in two tables.
    SELECT column_name FROM table_1INNER JOIN table_2ON table_1.column_name = table_2.column_name;

    Output: Above command will result in rows where both tables have matching values for column_name.

    INNER JOIN :INNER JOIN将在两个表中选择具有匹配值的记录。

    输出 :上面的命令将导致其中两个表的column_name值均匹配的行。

  3. INSERT: INSERT is used for adding a new row in the table.
    INSERT INTO table_name (column1, column2, column3) VALUES (value1, 'value2', value3);

    Output: Execution of this command will result in addition of a new row with values corresponding to the columns.

    INSERT :INSERT用于在表中添加新行。

    输出 :执行此命令将导致添加一个新行,并具有与各列相对应的值。

  4. LIKE: LIKE is an operator which is used for specifying a pattern. This operator is used along with WHERE clause.
    SELECT column_nameFROM table_nameWHERE column_name LIKE pattern;

    Output: Output will the rows that will satisfy the like pattern.

    LIKE :LIKE是用于指定模式的运算符。 该运算符与WHERE子句一起使用。

    输出 :将输出将满足类似模式的行。

  5. LIMIT: LIMIT is a clause which allows the restricting the result set rows to maximum number specified by the limit clause.
    SELECT column_nameFROM table_nameLIMIT number;

    Output: The resultset will be limited by the number that is provided as part of the limit clause.

    LIMIT :LIMIT是一个子句,它允许将结果集行限制为limit子句指定的最大数目。

    输出 :结果集将受到limit子句中提供的数字的限制。

  6. MAX: MAX is a function that will return the max value from the column specified.
    SELECT MAX(column_name)FROM table_name;

    Output: The output will the maximum value specified in the column column_name.

    MAX :MAX是一个函数,将从指定的列中返回最大值。

    输出 :输出将为column_name列中指定的最大值。

  7. MIN: MIN is a function that will return the min value from the column specified.
    SELECT MIN(column_name)FROM table_name;

    Output: The output will the minimum value specified in the column column_name.

    MIN :MIN是一个函数,将从指定的列中返回最小值。

    输出 :输出将为列column_name中指定的最小值。

  1. OR: OR is the operator that is used for selecting the rows based on satisfaction of either condition in WHERE clause.
    SELECT column_nameFROM table_nameWHERE column_name = value1OR column_name = value2;

    Output: Result set will contain rows where column_name value will be either value1 or value2.

    OR :OR是用于根据WHERE子句中任一条件的满足选择行的运算符。

    输出 :结果集将包含column_name值为value1或value2的行。

  2. ORDER BY: ORDER BY is used for sorting of columns in ascending or descending order numerically or in alphabetical order.
    SELECT column_nameFROM table_nameORDER BY column_name ASC;

    Output: On execution of the command above we will get the result set in ascending order.

    ORDER BY :ORDER BY用于按数字或字母顺序以升序或降序对列进行排序。

    输出 :执行上述命令后,我们将获得升序排列的结果集。

  3. LEFT JOIN, RIGHT JOIN: These will combine rows from different tables even if the join condition is not met. Every row in the left/right table is returned in the result set, and if the join condition is not met, then NULL values are filled in the columns from the left/right table.
    SELECT column_name(s) FROM table_1LEFT JOIN table_2ON table_1.column_name = table_2.column_name;

    Output: Execution of the command above will result in rows from the table_1 along with rows which satisfies the condition from table_2

    Output: Execution of the command above will result in rows from the table_2 along with rows which satisfies the condition from table_1.

    LEFT JOIN,RIGHT JOIN :即使不满足联接条件,它们也会合并来自不同表的行。 左/右表中的每一行都返回到结果集中,如果不满足连接条件,则在左/右表的列中填充NULL值。
    SELECT column_name(s) FROM table_1LEFT JOIN table_2ON table_1.column_name = table_2.column_name;

    输出:执行上面的命令将导致table_1中的行以及满足table_2中条件的行

    输出:上面命令的执行将导致table_2中的行以及满足table_1中条件的行。

  4. ROUND: ROUND is a function that rounds of the number specified in the column based on the integer that is specified as part of the function.
    SELECT ROUND(column_name, integer)FROM table_name;

    Output: The output of the command will result in rounding up the number based on the integer that is provided as part of the function.

    ROUND :ROUND是一个函数,它根据作为函数一部分指定的整数舍入列中指定的数字。

    输出 :命令的输出将导致根据函数的一部分提供的整数舍入数字。

  5. SELECT: SELECT is used to fetch the data from the data base.
    SELECT column_name FROM table_name

    Output: On execution of this command the result set will contain rows for column column_name.

    SELECT :SELECT用于从数据库中获取数据。

    输出 :执行此命令时,结果集将包含column_name列的行。

  6. SELECT DISTINCT: SELECT DISTINCT is used for retrieving distinct values from the column that is specified.
    SELECT DISTINCT column_name FROM table_name;

    Output: On execution of the command above the result set will only contain the unique values from the column column_name.

    SELECT DISTINCT :SELECT DISTINCT用于从指定的列中检索不同的值。

    输出 :执行以上命令时,结果集将仅包含column_name列中的唯一值。

  7. SUM: SUM is a function will provides the total value of a column which is numeric.
    SELECT SUM(column_name)FROM table_name;

    Output: Execution of this command will result in the total of all the row that are part of the column column_name.

    SUM :SUM是一个函数,它将提供数字列的总值。

    输出 :执行此命令将导致属于列column_name的所有行的总数。

  8. UPDATE: UPDATE is used for updating values of a row of a table.
    UPDATE table_nameSET some_column = some_valueWHERE some_column = some_value;

    Output: Execution of this command will result in updating the row that will satisfy the condition in the where clause.

    UPDATE :UPDATE用于更新表的一行的值。

    输出 :执行此命令将导致更新满足where子句中条件的行。

  9. WHERE: WHERE is used for specifying the condition that should be satisfied for selecting the row to be part of the result set.
    SELECT column_nameFROM table_nameWHERE column_name operator value;

    Output: The output of this command will result in the rows that are satisfying the where clause.

    WHERE :WHERE用于指定选择行作为结果集的一部分应满足的条件。

    输出 :此命令的输出将导致满足where子句的行。

That’s all for a quick roundup on mostly used SQL keywords.

这样就可以快速汇总最常用SQL关键字。

Reference:

参考:

翻译自:

sql关键字

转载地址:http://tymzd.baihongyu.com/

你可能感兴趣的文章
UIDynamic(物理仿真)
查看>>
Windows下安装Redis
查看>>
迷宫实现
查看>>
【字符编码】Java字符编码详细解答及问题探讨
查看>>
学习操作系统导图
查看>>
在线的JSON formate工具
查看>>
winform非常实用的程序退出方法!!!!!(转自博客园)
查看>>
xml解析
查看>>
centos安装vim
查看>>
linux工作调度(计划任务)
查看>>
hdu--1698 Just a Hook(线段树+区间更新+懒惰标记)
查看>>
Python学习笔记-EXCEL操作
查看>>
二月二——头牙诗词
查看>>
《吴忠与富平》之四:汉三水属国(北地属国、安定属国)
查看>>
丁酉立秋喜逢风雨
查看>>
vim删除#开头的行和正则表达式笔记
查看>>
python3 提成计算
查看>>
VBA赋值给指定单元格
查看>>
抽象类和接口总结回顾
查看>>
【语言处理与Python】5.3使用Python字典映射词及其属性
查看>>