Skip to content

Commit 0f19c50

Browse files
committed
updates
1 parent e9cc62c commit 0f19c50

File tree

3 files changed

+80
-26
lines changed

3 files changed

+80
-26
lines changed

docs/en/sql-reference/00-sql-reference/10-data-types/interval.md

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,45 @@ import FunctionDescription from '@site/src/components/FunctionDescription';
88

99
The INTERVAL data type represents a duration of time, allowing precise manipulation and storage of time intervals across various units.
1010

11-
- Supports units including `Millennium`, `Century`, `Decade`, `Year`, `Quarter`, `Month`, `Week`, `Day`, `Hour`, `Minute`, `Second`, `Millisecond`, and `Microsecond`.
1211
- Accepts natural language formats (e.g., '1 year 2 months ago') or numeric values interpreted as microseconds.
12+
13+
- Supports time units including `Millennium`, `Century`, `Decade`, `Year`, `Quarter`, `Month`, `Week`, `Day`, `Hour`, `Minute`, `Second`, `Millisecond`, and `Microsecond`.
14+
15+
```sql title='Examples:'
16+
-- Create a table with one INTERVAL column
17+
CREATE OR REPLACE TABLE intervals (duration INTERVAL);
18+
19+
-- Insert different types of INTERVAL data
20+
INSERT INTO intervals VALUES
21+
('1 year 2 months ago'), -- Natural language format with 'ago' (negative interval)
22+
('1 year 2 months'), -- Natural language format without 'ago' (positive interval)
23+
('1000000'), -- Positive numeric value interpreted as microseconds
24+
('-1000000'); -- Negative numeric value interpreted as microseconds
25+
26+
-- Query the table to see the results
27+
SELECT * FROM intervals;
28+
29+
┌──────────────────────────┐
30+
│ duration │
31+
├──────────────────────────┤
32+
-1 year -2 months │
33+
1 year 2 months │
34+
0:00:01
35+
-1 month -1 day -0:00:01
36+
└──────────────────────────┘
37+
```
38+
39+
- When given a numeric value, Databend only recognizes the integer part of the value. For example, both `TO_INTERVAL('1 seconds')` and `TO_INTERVAL('1.6 seconds')` represent an interval of 1 second. The fractional part after the decimal point is ignored.
40+
41+
```sql title='Examples:'
42+
SELECT TO_INTERVAL('1 seconds'), TO_INTERVAL('1.6 seconds');
43+
44+
┌───────────────────────────────────────────────────────┐
45+
│ to_interval('1 seconds') │ to_interval('1.6 seconds') │
46+
├──────────────────────────┼────────────────────────────┤
47+
│ 0:00:01 │ 0:00:01 │
48+
└───────────────────────────────────────────────────────┘
49+
```
1350
- Handles both positive and negative intervals with precision down to microseconds.
1451
- INTERVAL columns are *not* supported in the ORDER BY clause.
15-
- It is *not* recommended to use the MySQL client to query INTERVAL columns in Databend, as the MySQL protocol does not fully support the INTERVAL type. This may result in errors or unexpected behavior.
16-
17-
```sql title='Examples:'
18-
-- Create a table with one INTERVAL column
19-
CREATE OR REPLACE TABLE intervals (duration INTERVAL);
20-
21-
-- Insert different types of INTERVAL data
22-
INSERT INTO intervals VALUES
23-
('1 year 2 months ago'), -- Natural language format with 'ago' (negative interval)
24-
('1 year 2 months'), -- Natural language format without 'ago' (positive interval)
25-
('1000000'), -- Positive numeric value interpreted as microseconds
26-
('-1000000'); -- Negative numeric value interpreted as microseconds
27-
28-
-- Query the table to see the results
29-
SELECT * FROM intervals;
30-
31-
duration |
32-
------------------------+
33-
-1 year -2 months |
34-
1 year 2 months |
35-
0:00:01 |
36-
-1 month -1 day -0:00:01|
37-
```
52+
- It is *not* recommended to use the MySQL client to query INTERVAL columns in Databend, as the MySQL protocol does not fully support the INTERVAL type. This may result in errors or unexpected behavior.

docs/en/sql-reference/10-sql-commands/00-ddl/00-database/undrop-database.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,26 @@ See also: [DROP DATABASE](ddl-drop-database.md)
1212
UNDROP DATABASE <database_name>
1313
```
1414

15-
If a database with the same name already exists, an error is returned.
15+
- If a database with the same name already exists, an error is returned.
16+
17+
```sql title='Examples:'
18+
root@localhost:8000/default> CREATE DATABASE doc;
19+
processed in (0.030 sec)
20+
21+
root@localhost:8000/default> DROP DATABASE doc;
22+
processed in (0.028 sec)
23+
24+
root@localhost:8000/default> CREATE DATABASE doc;
25+
processed in (0.028 sec)
26+
27+
root@localhost:8000/default> UNDROP DATABASE doc;
28+
error: APIError: QueryFailed: [2301]Database 'doc' already exists
29+
```
30+
- Undropping a database does not automatically restore ownership to the original role. After undropping, ownership must be manually granted to the previous role or another role. Until then, the database will be accessible only to the `account-admin` role.
31+
32+
```sql title='Examples:'
33+
GRNAT OWNERSHIP on doc.* to ROLE writer;
34+
```
1635

1736
## Examples
1837

docs/en/sql-reference/10-sql-commands/00-ddl/01-table/21-ddl-undrop-table.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,27 @@ Restores the recent version of a dropped table. This leverages the Databend Time
1616
UNDROP TABLE [ <database_name>. ]<table_name>
1717
```
1818

19-
If a table with the same name already exists, an error is returned.
19+
- If a table with the same name already exists, an error is returned.
20+
21+
```sql title='Examples:'
22+
root@localhost:8000/default> CREATE TABLE t(id INT);
23+
processed in (0.036 sec)
24+
25+
root@localhost:8000/default> DROP TABLE t;
26+
processed in (0.033 sec)
27+
28+
root@localhost:8000/default> CREATE TABLE t(id INT, name STRING);
29+
processed in (0.030 sec)
30+
31+
root@localhost:8000/default> UNDROP TABLE t;
32+
error: APIError: QueryFailed: [2308]Undrop Table 't' already exists
33+
```
34+
35+
- Undropping a table does not automatically restore ownership to the original role. After undropping, ownership must be manually granted to the previous role or another role. Until then, the table will be accessible only to the `account-admin` role.
36+
37+
```sql title='Examples:'
38+
GRNAT OWNERSHIP on doc.t to ROLE writer;
39+
```
2040

2141
## Examples
2242

0 commit comments

Comments
 (0)