ClickHouse/docs/en/engines/database-engines/sqlite.md

51 lines
1.7 KiB
Markdown
Raw Normal View History

2021-08-15 14:11:37 +00:00
---
toc_priority: 32
toc_title: SQLite
---
# SQLite {#sqlite}
2021-08-15 13:53:49 +00:00
Allows to connect to [SQLite](https://www.sqlite.org/index.html) database.
2021-08-15 13:53:49 +00:00
## Creating a Database {#creating-a-database}
2021-08-15 16:34:10 +00:00
2021-08-15 13:53:49 +00:00
``` sql
2021-08-15 16:34:10 +00:00
CREATE DATABASE sqlite_database
ENGINE = SQLite('db_path')
2021-08-15 13:53:49 +00:00
```
**Engine Parameters**
2021-08-15 16:34:10 +00:00
- `db_path` — Path to SQLite file with the database.
## Data Types Support {#data_types-support}
2021-08-15 13:53:49 +00:00
| SQLite | ClickHouse |
2021-08-18 13:32:34 +00:00
|---------------|---------------------------------------------------------|
| INTEGER | [Int32](../../sql-reference/data-types/int-uint.md) |
| REAL | [Float32](../../sql-reference/data-types/float.md) |
| TEXT | [String](../../sql-reference/data-types/string.md) |
| BLOB | [String](../../sql-reference/data-types/string.md) |
2021-08-15 13:53:49 +00:00
## Specifics and Recommendations {#specifics-and-recommendations}
2021-08-15 13:53:49 +00:00
2021-08-15 16:34:10 +00:00
SQLite stores the entire database (definitions, tables, indices, and the data itself) as a single cross-platform file on a host machine. It is locking the entire database file during writing. SQLite read operations can be multitasked, though writes can only be performed sequentially.
SQLite does not require service management (such as startup scripts) or access control based on `GRANT` and passwords. Access control is handled by means of file-system permissions given to the database file itself.
2021-08-15 13:53:49 +00:00
## Usage Example {#usage-example}
2021-08-18 13:32:34 +00:00
Database in ClickHouse, exchanging data with the SQLite:
2021-08-15 13:53:49 +00:00
``` sql
2021-08-18 13:32:34 +00:00
CREATE DATABASE sqlite_db ENGINE = SQLite('sqlite.db');
SHOW TABLES FROM sqlite_db;
2021-08-15 13:53:49 +00:00
```
Result:
``` text
2021-08-18 13:32:34 +00:00
┌──name───┐
│ table1 │
│ table2 │
└─────────┘
```