2020-04-03 13:23:32 +00:00
---
toc_priority: 41
toc_title: url
---
2020-03-20 10:10:48 +00:00
# url {#url}
2018-07-27 10:21:04 +00:00
2021-01-19 22:39:12 +00:00
`url` function creates a table from the `URL` with given `format` and `structure` .
2018-07-27 10:21:04 +00:00
2021-01-19 23:02:46 +00:00
`url` function may be used in `SELECT` and `INSERT` queries on data in [URL ](../../engines/table-engines/special/url.md ) tables.
2018-07-27 10:21:04 +00:00
2021-01-19 22:39:12 +00:00
**Syntax**
2018-07-27 10:21:04 +00:00
2021-01-19 22:39:12 +00:00
``` sql
url(URL, format, structure)
```
2021-02-14 11:14:39 +00:00
**Parameters**
2021-01-19 22:39:12 +00:00
2021-02-26 14:28:56 +00:00
- `URL` — HTTP or HTTPS server address, which can accept `GET` or `POST` requests (for `SELECT` or `INSERT` queries correspondingly). Type: [String ](../../sql-reference/data-types/string.md ).
2021-02-14 11:14:39 +00:00
- `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 ).
2021-01-19 22:39:12 +00:00
**Returned value**
2021-02-14 11:14:39 +00:00
A table with the specified format and structure and with data from the defined `URL` .
2021-01-19 22:39:12 +00:00
**Examples**
2021-03-14 12:29:23 +00:00
Getting the first 3 lines of a table that contains columns of `String` and [UInt32 ](../../sql-reference/data-types/int-uint.md ) type from HTTP-server which answers in [CSV ](../../interfaces/formats.md#csv ) format.
2021-01-19 22:39:12 +00:00
``` sql
SELECT * FROM url('http://127.0.0.1:12345/', CSV, 'column1 String, column2 UInt32') LIMIT 3;
```
2018-07-27 10:21:04 +00:00
2021-02-14 11:14:39 +00:00
Inserting data from a `URL` into a table:
2018-07-27 10:21:04 +00:00
2020-03-20 10:10:48 +00:00
``` sql
2021-01-22 12:59:39 +00:00
CREATE TABLE test_table (column1 String, column2 UInt32) ENGINE=Memory;
INSERT INTO FUNCTION url('http://127.0.0.1:8123/?query=INSERT+INTO+test_table+FORMAT+CSV', 'CSV', 'column1 String, column2 UInt32') VALUES ('http interface', 42);
SELECT * FROM test_table;
2018-07-27 10:21:04 +00:00
```
2018-10-16 10:47:17 +00:00
2021-01-19 22:39:12 +00:00
[Original article ](https://clickhouse.tech/docs/en/sql-reference/table-functions/url/ ) <!--hide-->