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/scripts/sql/reference.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ You can use SQL to query data in SeaTable. If some tables in a base are archived
6
6
7
7
Currently only `select`, `insert`, `update`, and `delete` statements are supported. (`insert`, `update`, and `delete` statements require version 2.7 or later)
-`GROUP BY` uses strict syntax. The selected fields must appear in group by list, except for aggregation functions (`COUNT`, `SUM`, `MAX`, `MIN`, `AVG`) and formulas (see extended syntax section below).
38
38
-`HAVING` filters rows resulting from the group by clause. Only fields referred in the "GROUP BY" clause or aggregation functions (such as "SUM") can be used in having clause. Other syntax is the same as specified for the where clause.
39
39
- Fields in "order by" list must be a column or an expression in the selected fields. For example, `select a from table order by b` is invalid; while `select a from table order by b` and `select abs(a), b from table order by abs(a)` are valid.
40
-
- Limit options are in MySQL format. The general syntax is `LIMIT ... OFFSET ...`. You may obmit`LIMIT` or `OFFSET`.
40
+
- Limit options are in MySQL format. The general syntax is `LIMIT ... OFFSET ...`. You may omit`LIMIT` or `OFFSET`.
41
41
- Field alias with `AS` syntax is supported. For example, `select table.a as a from table` returns rows whose first column is keyed by "a". There are two notes:
42
42
- Field alias can be referred in `group by`, `having` and `order by` clauses. E.g., `select t.registration as r, count(*) as c from t group by r having c > 100` is valid.
43
43
- Field alias cannot be referred in `where` clause. E.g., `select t.registration as r, count(*) from t group by r where r > "2020-01-01"` will report syntax error.
44
44
45
45
Each returned row is a JSON map. The keys of the maps are the column keys, NOT column names. To use column names as keys, the `convert_keys` parameter (available since version 2.4) in query request should be TRUE. For JOIN query, the keys of row maps match the "id" fields (not the "key" or the "name"). Those column fields (e.g. id, key, name) are returned under `metadata` array in query response.
46
46
47
-
The synatx of `insert`, `update`, and `delete` statements are:
47
+
The syntax of `insert`, `update`, and `delete` statements are:
48
48
49
49
```
50
50
INSERT INTO table_name [column_list] VALUES value_list [, ...]
@@ -75,20 +75,20 @@ Below is mapping from SeaTable column types to SQL column types.
75
75
| SeaTable Column Type | SQL Column Type | Query result format | Use in WHERE clause | Use in GROUP BY / ORDER BY clause |
| long-text | String | Raw text in Markdown formst| Supported | Supported |
78
+
| long-text | String | Raw text in Markdown forms| Supported | Supported |
79
79
| number | Float || Supported | Supported |
80
80
| single-select | String | Returned rows contain the option key by default. To return the option name, the `convert_keys` parameter (available since version 2.4) in query request should be TRUE. | Refer an option by its name. E.g. `where single_select = "New York"`. | Order by the definition order of the options |
81
81
| multiple-select | List of strings | Returned rows contain the option key by default. To return the option name, the `convert_keys` parameter (available since version 2.4) in query request should be TRUE. | Refer an option by its name. E.g. `where multi_select = "New York"`. More details in "List Types" section below. | More details in "List Types" section below. |
82
82
| checkbox | Bool || Supported | Supported |
83
83
| date | Datetime | Time strings in RFC 3339 format | Constants are expressed in strings in ISO format. e.g. "2006-1-2" or "2006-1-2 15:04:05". Since 2.8 version, strings in RFC 3339 format are supported (such as "2020-12-31T23:59:60Z"). | Supported |
84
84
| image | List of URL for images | A JSON array with image URLs as elements | Supported. More details in "List Types" section below. | Supported. More details in "List Types" section below. |
85
85
| file | Will be returned as JSON format string when queried. | Not supported | Not Supported | Not Supported |
86
-
| collaborator | List of user IDs | Format is like [email protected]. If you need user names, you have to convert with seatable APIs. | Supported. More details in "List Types" section below. | Supported. More details in "List Types" section below. |
86
+
| collaborator | List of user IDs | Format is like [email protected]. If you need user names, you have to convert with Seatable APIs. | Supported. More details in "List Types" section below. | Supported. More details in "List Types" section below. |
87
87
| link to other records | List of linked rows | Supported. More details in "List Types" section below. | Supported. More details in "List Types" section below. | Supported. More details in "List Types" section below. |
88
88
| formula | The type depends on the return value of the formula. | Depends on the type of the return value | Depends on the type of the return value | Depends on the type of the return value |
89
-
|\_creator | User ID as stirng| Format is like [email protected]. If you need user names, you have to convert with seatable APIs. | Supported | Supported |
89
+
|\_creator | User ID as string| Format is like [email protected]. If you need user names, you have to convert with Seatable APIs. | Supported | Supported |
90
90
|\_ctime | Datetime | Time strings in RFC 3339 format | Constants are expressed in strings in ISO format. e.g. "2006-1-2" or "2006-1-2 15:04:05". Since 2.8 version, strings in RFC 3339 format are supported (such as "2020-12-31T23:59:60Z"). | Supported |
91
-
|\_last_modifier | User ID as string | Format is like [email protected]. If you need user names, you have to convert with seatable APIs. | Supported | Supported |
91
+
|\_last_modifier | User ID as string | Format is like [email protected]. If you need user names, you have to convert with Seatable APIs. | Supported | Supported |
92
92
|\_mtime | Datetime | Time strings in RFC 3339 format | Constants are expressed in strings in ISO format. e.g. "2006-1-2" or "2006-1-2 15:04:05". Since 2.8 version, strings in RFC 3339 format are supported (such as "2020-12-31T23:59:60Z"). | Supported |
93
93
| auto number | String || Supported | Supported. |
94
94
| url | String || Supported | Supported. |
@@ -160,19 +160,19 @@ In formulas, NULL values will be converted to 0 or an empty strings.
160
160
You may use a formula syntax that's almost the same as SeaTable's formulas in SQL queries. There are a few special notes:
161
161
162
162
- Link formulas are not supported. e.g. {link.age} is invalid.
163
-
- Reference to columns should not be enclosed by curly brackets ("{}"). Don't write `select abs({column}) from talbe;`. Wirte`select abs(column) from table;`. This is consistent with standard SQL syntax.
163
+
- Reference to columns should not be enclosed by curly brackets ("{}"). Don't write `select abs({column}) from table;`. Write`select abs(column) from table;`. This is consistent with standard SQL syntax.
164
164
- You can use back quote ("\`\`") to enclose column references, when column name contains space or "-". E.g. select abs(`column-a`) from table;
165
165
- You may not use column alias in formulas. E.g. `select abs(t.column) from table as t;` is invalid.
166
166
- formulas can be use in group by and order by clauses.
167
167
168
168
A few extended formulas are supported:
169
169
170
170
-`STARTOFWEEK(date, weekStart)`: returns the first day of the week where "date" is in. "weekstart" can be used to choose "sunday" or "monday" as the first day of a week.
171
-
-`Quarter(date)`: Returns the quater of the date. Return value is 1, 2, 3 or 4.
171
+
-`Quarter(date)`: Returns the quarter of the date. Return value is 1, 2, 3 or 4.
172
172
-`ISODate(date)`: Returns ISO format string for the date. E.g. "2020-09-08".
173
173
-`ISOMonth(date)`: Returns ISO format string for the month where "date" is in. E.g. "07".
174
174
175
-
The above formulas can be used for group by week, quater, date and month. E.g. `select sum(sale) from SalesRecord group by ISODate(SalesTime);` will return the total sales amount for each day.
175
+
The above formulas can be used for group by week, quarter, date and month. E.g. `select sum(sale) from SalesRecord group by ISODate(SalesTime);` will return the total sales amount for each day.
176
176
177
177
For more details, please refer to \[./function.md].
178
178
@@ -188,5 +188,5 @@ To improve query performance, SeaTable will automatically create indexes for the
188
188
189
189
When you add or delete a column in a table, the index for this column is not added/removed immediately. Indexes creation and deletion are triggered in two cases:
190
190
191
-
1. When you archive the table for the next time, indexes are created for new columns and indexes for remvoed columns are removed.
191
+
1. When you archive the table for the next time, indexes are created for new columns and indexes for removed columns are removed.
192
192
2. Users may manage indexes from "index management" UI. You can open it from the "Big data management" menu in the base.
0 commit comments