url.md 1.5 KB
Newer Older
I
Ivan Blinkov 已提交
1 2 3 4 5
---
toc_priority: 41
toc_title: url
---

6
# url {#url}
7

O
Olga Revyakina 已提交
8
`url` function creates a table from the `URL` with given `format` and `structure`.
9

O
Olga Revyakina 已提交
10
`url` function can be used in `SELECT` and `INSERT` queries on data in [URL](../../engines/table-engines/special/url.md) tables.
11

O
Olga Revyakina 已提交
12
**Syntax**
13

O
Olga Revyakina 已提交
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
``` sql
url(URL, format, structure)
```

**Input parameters**

- `URL` - HTTP or HTTPS server address, which can accept `GET` and/or `POST` requests. Type: [String](../../sql-reference/data-types/string.md).
- `format` - [Format](../../interfaces/formats.md#formats) of the data. Type: [String](../../sql-reference/data-types/string.md).
- `structure` - Table structure in `'UserID UInt64, Name String'` format. Determines column names and types. Type: [String](../../sql-reference/data-types/string.md).

**Returned value**

A table with the specified format and structure and with data from the defined URL.

**Examples**

Getting the first 3 lines of a table that contains columns of `String` and `UInt32` type from HTTP-server which answers in `CSV` format.

``` sql
SELECT * FROM url('http://127.0.0.1:12345/', CSV, 'column1 String, column2 UInt32') LIMIT 3;
```
35

O
Olga Revyakina 已提交
36
Inserting data from a URL into a table:
37

38
``` sql
O
Olga Revyakina 已提交
39 40 41
CREATE TABLE url_engine_table (column1 String, column2 UInt32) ENGINE=URL('http://127.0.0.1:12345/', CSV);
INSERT INTO url_engine_table FROM url('http://127.0.0.1:12345/', 'CSV', 'column1 String, column2 UInt32');
SELECT * FROM url_engine_table;
42
```
I
Ivan Blinkov 已提交
43

O
Olga Revyakina 已提交
44
[Original article](https://clickhouse.tech/docs/en/sql-reference/table-functions/url/) <!--hide-->