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: data-type-default-values.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ You can set default values for all data types. Typically, default values must be
14
14
- For integer types, you can use the `NEXT VALUE FOR` function to set the next value of a sequence as the default value for a column, and use the [`RAND()`](/functions-and-operators/numeric-functions-and-operators.md) function to generate a random floating-point value as the default value for a column.
15
15
- For string types, you can use the [`UUID()`](/functions-and-operators/miscellaneous-functions.md) function to generate a [universally unique identifier (UUID)](/best-practices/uuid.md) as the default value for a column.
16
16
- For binary types, you can use the [`UUID_TO_BIN()`](/functions-and-operators/miscellaneous-functions.md) function to convert a UUID to the binary format and set the converted value as the default value for a column.
17
-
- Starting from v8.0.0, TiDB additionally supports [specifying the default values](#specify-expressions-as-default-values) for [`BLOB`](/data-type-string.md#blob-type), [`TEXT`](/data-type-string.md#text-type), and [`JSON`](/data-type-json.md#json-type) data types, but you can only use expressions to set the [default values](#default-values) for them.
17
+
- Starting from v8.0.0, TiDB additionally supports [specifying the default values](#specify-expressions-as-default-values) for [`BLOB`](/data-type-string.md#blob-type), [`TEXT`](/data-type-string.md#text-type), and [`JSON`](/data-type-json.md#json-data-type) data types, but you can only use expressions to set the [default values](#default-values) for them.
18
18
19
19
If a column definition includes no explicit `DEFAULT` value, TiDB determines the default value as follows:
TiDB supports the `JSON` (JavaScript Object Notation) data type, which is useful for storing semi-structured data. The `JSON` data type provides the following advantages over storing `JSON`-format strings in a string column:
10
10
@@ -26,6 +26,27 @@ SELECT id FROM city WHERE population >= 100;
26
26
27
27
For more information, see [JSON Functions](/functions-and-operators/json-functions.md) and [Generated Columns](/generated-columns.md).
28
28
29
+
## JSON value types
30
+
31
+
The values inside a JSON document have types. This is visible in the output of [`JSON_TYPE`()](/functions-and-operators/json-functions/json-functions-return.md#json_type).
- Currently, TiDB only supports pushing down limited `JSON` functions to TiFlash. For more information, see [Push-down expressions](/tiflash/tiflash-supported-pushdown-calculations.md#push-down-expressions).
@@ -102,4 +123,4 @@ For more information, see [JSON Functions](/functions-and-operators/json-functio
102
123
INSERT INTO t VALUES (3);
103
124
```
104
125
105
-
For more information about the `JSON` data type, see [JSON functions](/functions-and-operators/json-functions.md) and [Generated Columns](/generated-columns.md).
126
+
For more information about the `JSON` data type, see [JSON functions](/functions-and-operators/json-functions.md) and [Generated Columns](/generated-columns.md).
|[`COUNT()`](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_count)| Return a count of the number of rows returned |
18
18
|[`COUNT(DISTINCT)`](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_count-distinct)| Return the count of a number of different values |
19
19
|[`SUM()`](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_sum)| Return the sum |
20
20
|[`AVG()`](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_avg)| Return the average value of the argument |
21
21
|[`MAX()`](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_max)| Return the maximum value |
22
22
|[`MIN()`](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_min)| Return the minimum value |
23
-
|[`GROUP_CONCAT()`](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_group-concat)| Return a concatenated string |
24
-
|[`VARIANCE()`, `VAR_POP()`](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_var-pop)| Return the population standard variance|
25
-
|[`STD()`, `STDDEV()`, `STDDEV_POP`](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_std)| Return the population standard deviation |
26
-
|[`VAR_SAMP()`](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_var-samp)| Return the sample variance |
27
-
|[`STDDEV_SAMP()`](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_stddev-samp)| Return the sample standard deviation |
28
-
|[`JSON_OBJECTAGG(key, value)`](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_json-objectagg)| Return the result set as a single JSON object containing key-value pairs |
23
+
|[`GROUP_CONCAT()`](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_group-concat)| Return a concatenated string |
24
+
|[`VARIANCE()`, `VAR_POP()`](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_var-pop)| Return the population standard variance |
25
+
|[`STD()`, `STDDEV()`, `STDDEV_POP`](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_std)| Return the population standard deviation |
26
+
|[`VAR_SAMP()`](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_var-samp)| Return the sample variance |
27
+
|[`STDDEV_SAMP()`](https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html#function_stddev-samp)| Return the sample standard deviation |
28
+
|[`JSON_ARRAYAGG()`](/functions-and-operators/json-functions/json-functions-aggregate.md#json_arrayagg)| Return the result set as a single JSON array |
29
+
|[`JSON_OBJECTAGG()`](/functions-and-operators/json-functions/json-functions-aggregate.md#json_objectagg)| Return the result set as a single JSON object containing key-value pairs |
29
30
30
31
- Unless otherwise stated, group functions ignore `NULL` values.
31
32
- If you use a group function in a statement containing no `GROUP BY` clause, it is equivalent to grouping on all rows.
@@ -40,23 +41,19 @@ In addition, TiDB also provides the following aggregate functions:
40
41
41
42
The following example shows how to calculate the fiftieth percentile of a `INT` column:
42
43
43
-
{{< copyable "sql" >}}
44
-
45
44
```sql
46
-
droptable if exists t;
47
-
createtablet(a int);
48
-
insert into t values(1), (2), (3);
45
+
DROPTABLE IF EXISTS t;
46
+
CREATETABLEt(a INT);
47
+
INSERT INTO t VALUES(1), (2), (3);
49
48
```
50
49
51
-
{{< copyable "sql">}}
52
-
53
50
```sql
54
-
select approx_percentile(a, 50) from t;
51
+
SELECT APPROX_PERCENTILE(a, 50) FROM t;
55
52
```
56
53
57
54
```sql
58
55
+--------------------------+
59
-
| approx_percentile(a, 50) |
56
+
| APPROX_PERCENTILE(a, 50) |
60
57
+--------------------------+
61
58
| 2 |
62
59
+--------------------------+
@@ -153,4 +150,4 @@ group by id, val;
153
150
154
151
## Related system variables
155
152
156
-
The `group_concat_max_len` variable sets the maximum number of items for the `GROUP_CONCAT()` function.
153
+
The [`group_concat_max_len`](/system-variables.md#group_concat_max_len) variable sets the maximum number of items for the `GROUP_CONCAT()` function.
0 commit comments