You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/en/sql-reference/10-sql-commands/20-query-syntax/values.md
+25-41Lines changed: 25 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,24 +5,28 @@ import FunctionDescription from '@site/src/components/FunctionDescription';
5
5
6
6
<FunctionDescriptiondescription="Introduced or updated: v1.2.65"/>
7
7
8
-
The VALUES clause is used to define a set of rows explicitly for use in queries. It allows you to provide a list of values that can be used as a temporary table in your SQL statements.
8
+
The VALUES clause creates an inline table by explicitly defining rows of data. This temporary table can be used directly or within other SQL statements.
- The VALUES clause is followed by sets of values enclosed in parentheses.
16
-
- Each set of values represents a row to be inserted into the temporary table.
17
-
- Within each set of values, the individual values are comma-separated and correspond to the columns of the temporary table.
18
-
- Databend automatically assigns default column names like *col0*, *col1*, *col2*, and so on when you insert multiple rows without specifying column names.
17
+
18
+
**Key Points:**
19
+
- The VALUES clause must be enclosed in parentheses when used in a FROM clause: `FROM (VALUES ...)`
20
+
- Each parenthesized group of expressions represents one row
21
+
- Column names are automatically assigned as **col0**, **col1**, etc. (zero-based indexing)
22
+
- You can provide custom column names using table aliases
19
23
20
24
## Examples
21
25
22
-
These examples demonstrate using the VALUES clause to show city data in various formats: directly, or ordered by population:
26
+
### Basic Usage
23
27
24
28
```sql
25
-
--Directly return data
29
+
--Direct usage with automatic column names (col0, col1)
> **Important**: When using VALUES in a FROM clause or CTE, it must be enclosed in parentheses: `FROM (VALUES ...)` or `AS (VALUES ...)`. This is required syntax.
0 commit comments