{"id":313478,"date":"2020-11-20T09:02:38","date_gmt":"2020-11-20T09:02:38","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=313478"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=313478","title":{"rendered":"\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 SQLite, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u043c\u043e\u0433\u043b\u0438 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 SQLite, \u043d\u043e \u043d\u0435 \u0441\u043b\u0435\u0434\u0438\u0442\u0435 <a href=\"https:\/\/www.sqlite.org\/changes.html\" rel=\"nofollow\">\u0437\u0430 \u0435\u0433\u043e \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435\u043c<\/a>, \u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0435\u0449\u0438, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u0434 \u043f\u0440\u043e\u0449\u0435, \u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u043f\u0440\u043e\u0448\u043b\u0438 \u043d\u0435\u0437\u0430\u043c\u0435\u0447\u0435\u043d\u043d\u044b\u043c\u0438. \u041f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0432\u0430\u0436\u043d\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h3><a href=\"https:\/\/www.sqlite.org\/partialindex.html\" rel=\"nofollow\">\u0427\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b<\/a> (Partial Indexes)<\/h3>\n<p>\u041f\u0440\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0438\u043d\u0434\u0435\u043a\u0441, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443, \u043e\u0434\u043d\u0430 \u0438\u0437 \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u043d\u0435 \u043f\u0443\u0441\u0442\u0430\u044f, \u0430 \u0434\u0440\u0443\u0433\u0430\u044f \u0440\u0430\u0432\u043d\u0430 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e. <\/p>\n<pre><code class=\"sql\">create index idx_partial on tab1(a, b) where a is not null and b = 5; select * from tab1 where a is not null and b = 5; --&gt; search table tab1 using index<\/code><\/pre>\n<p>  <\/p>\n<h3><a href=\"https:\/\/www.sqlite.org\/expridx.html\" rel=\"nofollow\">\u0418\u043d\u0434\u0435\u043a\u0441\u044b \u043d\u0430 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435<\/a> (Indexes On Expressions)<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445 \u043a \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441 \u043f\u043e \u043d\u0435\u043c\u0443. \u041e\u0434\u043d\u0430\u043a\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0432 \u0432\u0438\u0434\u0443, \u0447\u0442\u043e \u043f\u043e\u043a\u0430 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0442\u043e\u0440 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0433\u0438\u0431\u043e\u043a \u0438 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0432 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a \u043e\u0442\u043a\u0430\u0437\u0443 \u043e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430.<\/p>\n<pre><code class=\"sql\">create index idx_expression on tab1(a + b); select * from tab1 where a + b &gt; 10; --&gt; search table tab1 using index ... select * from tab1 where b + a &gt; 10; --&gt; scan table<\/code><\/pre>\n<p>  <\/p>\n<h3><a href=\"https:\/\/www.sqlite.org\/gencol.html\" rel=\"nofollow\">\u0412\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u043c\u044b\u0435 \u043a\u043e\u043b\u043e\u043d\u043a\u0438<\/a> (Generated Columns)<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u0430 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u043e\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u043e \u0434\u0440\u0443\u0433\u0438\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u0442\u043e\u043b\u0431\u0435\u0446. \u0415\u0441\u0442\u044c \u0434\u0432\u0430 \u0432\u0438\u0434\u0430: VIRTUAL (\u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043f\u0440\u0438 \u0447\u0442\u0435\u043d\u0438\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u043d\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043c\u0435\u0441\u0442\u0430) \u0438 STORED (\u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0438 \u043c\u0435\u0441\u0442\u043e \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442). \u0420\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0442\u0430\u043a\u0438\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043d\u0435\u043b\u044c\u0437\u044f.<\/p>\n<pre><code class=\"sql\">create table tab1 ( \ta integer primary key, \tb int, \tc text, \td int generated always as (a * abs(b)) virtual, \te text generated always as (substr(c, b, b + 1)) stored );<\/code><\/pre>\n<p>  <\/p>\n<h3><a href=\"https:\/\/www.sqlite.org\/rtree.html\" rel=\"nofollow\">R-Tree \u0438\u043d\u0434\u0435\u043a\u0441<\/a><\/h3>\n<p>\u0418\u043d\u0434\u0435\u043a\u0441 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u043f\u043e\u0438\u0441\u043a\u0430 \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439\/\u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u0442.\u0435. \u0437\u0430\u0434\u0430\u0447\u0438 \u0442\u0438\u043f\u0438\u0447\u043d\u043e\u0439 \u0434\u043b\u044f \u0433\u0435\u043e-\u0441\u0438\u0441\u0442\u0435\u043c, \u043a\u043e\u0433\u0434\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u044b-\u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0438 \u0437\u0430\u0434\u0430\u043d\u044b \u0441\u0432\u043e\u0435\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0435\u0439 \u0438 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c \u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0430\u0439\u0442\u0438 \u0432\u0441\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u044e\u0442\u0441\u044f \u0441 \u0442\u0435\u043a\u0443\u0449\u0438\u043c. \u0414\u0430\u043d\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0432 \u0432\u0438\u0434\u0435 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b (\u0441\u043c. \u043d\u0438\u0436\u0435) \u0438 \u044d\u0442\u043e \u0438\u043d\u0434\u0435\u043a\u0441 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u0441\u0432\u043e\u0435\u0439 \u0441\u0443\u0442\u0438. \u0414\u043b\u044f \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438 R-Tree \u0438\u043d\u0434\u0435\u043a\u0441\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u043e\u0431\u0440\u0430\u0442\u044c SQLite \u0441 \u0444\u043b\u0430\u0433\u043e\u043c <code>SQLITE_ENABLE_RTREE<\/code> (\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d).<\/p>\n<pre><code class=\"sql\">create virtual table idx_rtree using rtree ( \tid,              -- \u043a\u043b\u044e\u0447 \tminx, maxx,      -- \u043c\u0438\u043d \u0438 \u043c\u0430\u043ac x \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \tminy, maxy,      -- \u043c\u0438\u043d \u0438 \u043c\u0430\u043ac y \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \tdata             -- \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435   );    insert into idx_rtree values (1, -80.7749, -80.7747, 35.3776, 35.3778);  insert into idx_rtree values (2, -81.0, -79.6, 35.0, 36.2);  select id from idx_rtree  where minx &gt;= -81.08 and maxx &lt;= -80.58 and miny &gt;= 35.00  and maxy &lt;= 35.44; <\/code><\/pre>\n<p>  <\/p>\n<h3><a href=\"https:\/\/sqlite.org\/lang_altertable.html\" rel=\"nofollow\">\u041f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043b\u043e\u043d\u043a\u0438<\/a><\/h3>\n<p>\u0412 SQLite \u0441\u043b\u0430\u0431\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0442\u0430\u0431\u043b\u0438\u0446, \u0442\u0430\u043a, \u043f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043d\u0435\u043b\u044c\u0437\u044f \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 (constraint) \u0438\u043b\u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0441\u0442\u043e\u043b\u0431\u0435\u0446. \u0421 \u0432\u0435\u0440\u0441\u0438\u0438 3.25.0 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u043e\u043b\u0431\u0435\u0446, \u043d\u043e \u043d\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u0442\u0438\u043f.<\/p>\n<pre><code class=\"sql\">alter table tbl1 rename column a to b;<\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0434\u0440\u0443\u0433\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0432\u0441\u0451 \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441 \u043d\u0443\u0436\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439, \u043f\u0435\u0440\u0435\u043b\u0438\u0442\u044c \u0442\u0443\u0434\u0430 \u0434\u0430\u043d\u043d\u044b\u0435, \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0441\u0442\u0430\u0440\u0443\u044e \u0438 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e.<\/p>\n<h3><a href=\"https:\/\/www.sqlite.org\/lang_UPSERT.html\" rel=\"nofollow\">\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443, \u0438\u043d\u0430\u0447\u0435 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c<\/a> (Upsert)<\/h3>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043a\u043b\u0430\u0441\u0441 <code>on conflict<\/code> \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <code>insert<\/code>, \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443, \u0430 \u043f\u0440\u0438 \u0443\u0436\u0435 \u0438\u043c\u0435\u044e\u0449\u0435\u0439\u0441\u044f \u0441 \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u043f\u043e \u043a\u043b\u044e\u0447\u0443, \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c. <\/p>\n<pre><code class=\"sql\">create table vocabulary (word text primary key, count int default 1); insert into vocabulary (word) values ('jovial')    on conflict (word) do update set count = count + 1;<\/code><\/pre>\n<p>  <\/p>\n<h3><a href=\"https:\/\/www.sqlite.org\/lang_update.html#upfrom\" rel=\"nofollow\">\u041e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 Update from<\/a><\/h3>\n<p>\u0415\u0441\u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u0440\u0443\u0433\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0442\u043e \u0440\u0430\u043d\u0435\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430 \u0438\u043b\u0438 <code>with<\/code>. \u0421 \u0432\u0435\u0440\u0441\u0438\u0438 3.33.0 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <code>update<\/code> \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u0441\u043b\u043e\u0432\u043e\u043c <code>from<\/code> \u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a<\/p>\n<pre><code class=\"sql\">update inventory    set quantity = quantity - daily.amt   from (select sum(quantity) as amt, itemid from sales group by 2) as daily  where inventory.itemid = daily.itemid;<\/code><\/pre>\n<p>  <\/p>\n<h3><a href=\"https:\/\/sqlite.org\/lang_with.html\" rel=\"nofollow\">CTE \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u043a\u043b\u0430\u0441\u0441 with<\/a> (Common Table Expression)<\/h3>\n<p>\u041a\u043b\u0430\u0441\u0441 <code>with<\/code> \u043c\u043e\u0436\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u0412 \u0432\u0435\u0440\u0441\u0438\u0438 3.34.0 \u0437\u0430\u044f\u0432\u043b\u0435\u043d\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f <code>with<\/code> \u0432\u043d\u0443\u0442\u0440\u0438 <code>with<\/code>.<\/p>\n<pre><code class=\"sql\">with tab2 as (select * from tab1 where a &gt; 10),    tab3 as (select * from tab2 inner join ...) select * from tab3; <\/code><\/pre>\n<p>  \u0421 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 <code>recursive<\/code>, <code>with<\/code> \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u0433\u0434\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043e\u043f\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438. <\/p>\n<pre><code class=\"sql\">-- \u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 with recursive cnt(x) as (   values(1) union all select x + 1 from cnt where x &lt; 1000 ) select x from cnt;  -- \u041d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u043b\u0438 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044f \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0441 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0435\u0439 create table tab1 (id, parent_id); insert into tab1 values    (1, null), (10, 1), (11, 1), (12, 10), (13, 10),   (2, null), (20, 2), (21, 2), (22, 20), (23, 21);  -- \u0423\u0437\u043b\u044b \u043d\u0438\u0436\u0435 \u043f\u043e \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 with recursive tc (id) as ( \tselect id from tab1 where id = 10\t \tunion  \tselect tab1.id from tab1, tc where tab1.parent_id = tc.id )  -- \u0423\u0437\u0435\u043b\u044b \u0432\u0435\u0440\u0445\u043d\u0435\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u0434\u043b\u044f \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0445 with recursive tc (id, parent_id) as ( \tselect id, parent_id from tab1 where id in (12, 21) \tunion  \tselect tc.parent_id, tab1.parent_id  \tfrom tab1, tc where tab1.id = tc.parent_id ) select distinct id from tc where parent_id is null order by 1;  -- \u0424\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0442\u0441\u0442\u0443\u043f\u043e\u0432 \u043f\u0440\u0438 \u0432\u044b\u0432\u043e\u0434\u0435, \u043d\u0430\u043f\u0440. \u0434\u043b\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043e\u0442\u0434\u0435\u043b\u043e\u0432 create table org(name text primary key, boss text references org); insert into org values ('Alice', null),    ('Bob', 'Alice'), ('Cindy', 'Alice'), ('Dave', 'Bob'),    ('Emma', 'Bob'), ('Fred', 'Cindy'), ('Gail', 'Cindy');  with recursive   under_alice (name, level) as (     values('Alice', 0)     union all     select org.name, under_alice.level + 1       from org join under_alice on org.boss = under_alice.name      order by 2   ) select substr('..........', 1, level * 3) || name from under_alice;<\/code><\/pre>\n<p>  <\/p>\n<h3><a href=\"https:\/\/sqlite.org\/windowfunctions.html\" rel=\"nofollow\">\u041e\u043a\u043e\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<\/a> (Window Functions)<\/h3>\n<p>\u0421 \u0432\u0435\u0440\u0441\u0438\u0438 3.25.0 \u0432 SQLite \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043e\u043a\u043e\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0442\u0430\u043a\u0436\u0435 \u0438\u043d\u043e\u0433\u0434\u0430 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0435 \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u043d\u0430\u0434 \u0447\u0430\u0441\u0442\u044c\u044e \u0434\u0430\u043d\u043d\u044b\u0445 (\u043e\u043a\u043d\u043e\u043c).<\/p>\n<pre><code class=\"sql\">-- \u041d\u043e\u043c\u0435\u0440 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 create table tab1 (x integer primary key, y text); insert into tab1 values (1, 'aaa'), (2, 'ccc'), (3, 'bbb'); select x, y, row_number() over (order by y) as row_number from tab1 order by x;  -- \u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 create table tab1 (a integer primary key, b, c); insert into tab1 values (1, 'A', 'one'),   (2, 'B', 'two'), (3, 'C', 'three'), (4, 'D', 'one'),    (5, 'E', 'two'), (6, 'F', 'three'), (7, 'G', 'one');  -- \u0414\u043e\u0441\u0442\u0443\u043f \u043a \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u043e\u043a\u043d\u0435 select a, b, group_concat(b, '.') over (order by a rows between 1 preceding and 1 following) as prev_curr_next from tab1;  -- \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u043e\u043a\u043d\u0435 (\u0433\u0440\u0443\u043f\u043f\u0435, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c\u043e\u0439 \u043a\u043e\u043b\u043e\u043d\u043a\u043e\u0439 c)  \u043e\u0442 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0434\u043e \u043a\u043e\u043d\u0446\u0430 \u043e\u043a\u043d\u0430 select c, a, b, group_concat(b, '.') over (partition by c order by a range between current row and unbounded following) as curr_end from tab1 order by c, a;  -- \u041f\u0440\u043e\u043f\u0443\u0441\u043a \u0441\u0442\u0440\u043e\u043a \u0432 \u043e\u043a\u043d\u0435 \u043f\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044e select c, a, b, group_concat(b, '.') filter (where c &lt;&gt; 'two') over (order by a) as exceptTwo from t1 order by a; <\/code><\/pre>\n<p>  <\/p>\n<h3>\u0423\u0442\u0438\u043b\u0438\u0442\u044b SQLite<\/h3>\n<p>\u041f\u043e\u043c\u0438\u043c\u043e CLI <a href=\"https:\/\/sqlite.org\/cli.html\" rel=\"nofollow\">sqlite3<\/a> \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0435\u0449\u0435 \u0434\u0432\u0435 \u0443\u0442\u0438\u043b\u0438\u0442\u044b. \u041f\u0435\u0440\u0432\u0430\u044f \u2014 <a href=\"https:\/\/sqlite.org\/sqldiff.html\" rel=\"nofollow\">sqldiff<\/a>, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0431\u0430\u0437\u044b (\u0438\u043b\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443) \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435, \u043d\u043e \u0438 \u043f\u043e \u0434\u0430\u043d\u043d\u044b\u043c. \u0412\u0442\u043e\u0440\u0430\u044f \u2014 <a href=\"https:\/\/www.sqlite.org\/sqlanalyze.html\" rel=\"nofollow\">sqlite3_analizer<\/a> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u0435\u0441\u0442\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438 \u0438 \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u043c\u0438 \u0432 \u0444\u0430\u0439\u043b\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445. \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0437 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b <a href=\"https:\/\/www.sqlite.org\/dbstat.html\" rel=\"nofollow\">dbstat<\/a> (\u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0444\u043b\u0430\u0433 <code>SQLITE_ENABLE_DBSTAT_VTAB<\/code> \u043f\u0440\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 SQLite).<\/p>\n<p>  \u0421 \u0432\u0435\u0440\u0441\u0438\u0438 3.22.0 CLI sqlite3 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 (\u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u0443\u044e) \u043a\u043e\u043c\u0430\u043d\u0434\u0443 .expert, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u0430\u043a\u043e\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u0441\u0442\u043e\u0438\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u043b\u044f \u0432\u0432\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/p>\n<h3><a href=\"https:\/\/sqlite.org\/lang_vacuum.html\" rel=\"nofollow\">\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0440\u0435\u0437\u0435\u0440\u0432\u043d\u043e\u0439 \u043a\u043e\u043f\u0438\u0438 Vacuum Into<\/a><\/h3>\n<p>\u0421 \u0432\u0435\u0440\u0441\u0438\u0438 3.27.0 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <code>vacuum<\/code> \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0430 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u0441\u043b\u043e\u0432\u043e\u043c <code>into<\/code>, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043e\u043f\u0438\u044e \u0431\u0430\u0437\u044b \u0431\u0435\u0437 \u0435\u0451 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043f\u0440\u044f\u043c\u043e \u0438\u0437 SQL. \u042f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043e\u0439 <a href=\"https:\/\/www.sqlite.org\/backup.html\" rel=\"nofollow\">Backup API<\/a>.<\/p>\n<pre><code class=\"sql\">vacuum into 'D:\/backup\/' || strftime('%Y-%M-%d', 'now') || '.sqlite';<\/code><\/pre>\n<p>   <\/p>\n<h3><a href=\"https:\/\/sqlite.org\/printf.html\" rel=\"nofollow\">\u0424\u0443\u043d\u043a\u0446\u0438\u044f printf<\/a><\/h3>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0430\u043d\u0430\u043b\u043e\u0433\u043e\u043c \u0421-\u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c <code>NULL<\/code>-\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u043f\u0443\u0441\u0442\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0434\u043b\u044f <code>%s<\/code> \u0438 <code>0<\/code> \u0434\u043b\u044f \u043f\u043b\u0435\u0439\u0441\u0445\u043e\u043b\u0434\u0435\u0440\u0430 \u0447\u0438\u0441\u043b\u0430. <\/p>\n<pre><code class=\"sql\">select 'a' || ' 123 ' || null; --&gt; null select printf('%s %i %s', 'a', 123, null); --&gt; 123 a select printf('%s %i %i', 'a', 123, null); --&gt; 123 a 0 <\/code><\/pre>\n<p>  <\/p>\n<h3><a href=\"https:\/\/sqlite.org\/lang_datefunc.html\" rel=\"nofollow\">\u0412\u0440\u0435\u043c\u044f \u0438 \u0434\u0430\u0442\u0430<\/a><\/h3>\n<p>\u0412 SQLite <a href=\"https:\/\/www.sqlite.org\/datatype3.html\" rel=\"nofollow\"><code>\u043d\u0435\u0442 \u0442\u0438\u043f\u043e\u0432 Date<\/code> \u0438 <code>Time<\/code><\/a>. \u0425\u043e\u0442\u044f \u0438 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u0441 \u043a\u043e\u043b\u043e\u043d\u043a\u0430\u043c\u0438 \u0442\u0430\u043a\u0438\u0445 \u0442\u0438\u043f\u043e\u0432, \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0431\u0435\u0437 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0442\u0438\u043f\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0442\u0430\u043a\u0438\u0445 \u043a\u043e\u043b\u043e\u043d\u043a\u0430\u0445 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u043a\u0430\u043a \u0442\u0435\u043a\u0441\u0442. \u042d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u043f\u0440\u0438 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u043e\u0434\u043d\u0430\u043a\u043e \u0438\u043c\u0435\u0435\u0442 \u0440\u044f\u0434 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432: \u043d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a, \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441\u0430, \u0434\u0430\u043d\u043d\u044b\u0435 \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442 \u043c\u043d\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430, \u043e\u0442\u0441\u0443\u0442\u0441\u0432\u0443\u0435\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0437\u043e\u043d\u0430. \u0414\u043b\u044f \u0438\u0437\u0431\u0435\u0436\u0430\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043a\u0430\u043a <a href=\"https:\/\/ru.wikipedia.org\/wiki\/Unix-%D0%B2%D1%80%D0%B5%D0%BC%D1%8F\" rel=\"nofollow\">unix-\u0432\u0440\u0435\u043c\u044f<\/a>, \u0442.\u0435. \u0447\u0438\u0441\u043b\u043e \u0441\u0435\u043a\u0443\u043d\u0434, \u043f\u0440\u043e\u0448\u0435\u0434\u0448\u0438\u0445 \u0441 \u043f\u043e\u043b\u0443\u043d\u043e\u0447\u0438 01.01.1970.<\/p>\n<pre><code class=\"sql\">select strftime('%Y-%M-%d %H:%m', 'now'); --&gt; UTC \u0432\u0440\u0435\u043c\u044f select strftime('%Y-%M-%d %H:%m', 'now', 'localtime'); --&gt; \u043c\u0435\u0441\u0442\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f select strftime('%s', 'now'); -- \u0442\u0435\u043a\u0443\u0449\u0435\u0435 Unix-\u0432\u0440\u0435\u043c\u044f  select strftime('%s', 'now', '+2 day'); --&gt; \u0442\u0435\u043a\u0443\u0449\u0435\u0435 unix-\u0432\u0440\u0435\u043c\u044f \u043f\u043b\u044e\u0441 \u0434\u0432\u0430 \u0434\u043d\u044f -- \u041a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044f unix-\u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f - 21-11-2020 15:25:14 select strftime('%d-%m-%Y %H:%M:%S', 1605961514, 'unixepoch', 'localtime')<\/code><\/pre>\n<p>  <\/p>\n<h3><a href=\"https:\/\/www.sqlite.org\/json1.html\" rel=\"nofollow\">Json<\/a><\/h3>\n<p>\u0421 \u0432\u0435\u0440\u0441\u0438\u0438 3.9.0 \u0432 SQLite \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 json (\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043b\u0438\u0431\u043e \u0444\u043b\u0430\u0433 <code>SQLITE_ENABLE_JSON1<\/code> \u043f\u0440\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0438\u043b\u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435). \u0414\u0430\u043d\u043d\u044b\u0435 json \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u043a\u0430\u043a \u0442\u0435\u043a\u0441\u0442. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u2014 \u0442\u0430\u043a\u0436\u0435 \u0442\u0435\u043a\u0441\u0442.<\/p>\n<pre><code class=\"sql\">select json_array(1, 2, 3); --&gt; [1,2,3] (\u0441\u0442\u0440\u043e\u043a\u0430) select json_array_length(json_array(1, 2, 3)); --&gt; 3 select json_array_length('[1,2,3]'); --&gt; 3 select json_object('a', json_array(2, 5), 'b', 10); --&gt; {&quot;a&quot;:[2,5],&quot;b&quot;:10} (\u0441\u0442\u0440\u043e\u043a\u0430) select json_extract('{&quot;a&quot;:[2,5],&quot;b&quot;:10}', '$.a[0]');  --&gt; 2 select json_insert('{&quot;a&quot;:[2,5]}', '$.c', 10); --&gt; {&quot;a&quot;:[2,5],&quot;c&quot;:10} (\u0441\u0442\u0440\u043e\u043a\u0430) select value from json_each(json_array(2, 5)); --&gt; 2 \u0441\u0442\u0440\u043e\u043a\u0438 2, 5 select json_group_array(value) from json_each(json_array(2, 5)); --&gt; [2,5] (\u0441\u0442\u0440\u043e\u043a\u0430)<\/code><\/pre>\n<p>  <\/p>\n<h3><a href=\"https:\/\/www.sqlite.org\/fts5.html\" rel=\"nofollow\">\u041f\u043e\u043b\u043d\u043e\u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u043f\u043e\u0438\u0441\u043a<\/a><\/h3>\n<p>\u041a\u0430\u043a \u0438 json, \u043f\u043e\u043b\u043d\u043e\u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u043f\u043e\u0438\u0441\u043a \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0444\u043b\u0430\u0433\u0430 <code>SQLITE_ENABLE_FTS5<\/code> \u043f\u0440\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0438\u043b\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u043e\u0438\u0441\u043a\u043e\u043c, \u0441\u043f\u0435\u0440\u0432\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u0443\u0435\u043c\u044b\u043c\u0438 \u043f\u043e\u043b\u044f\u043c\u0438, \u0430 \u0438 \u043f\u043e\u0442\u043e\u043c \u0442\u0443\u0434\u0430 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u044e\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043e\u0431\u044b\u0447\u043d\u044b\u0439 <code>insert<\/code>. \u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0432 \u0432\u0438\u0434\u0443, \u0447\u0442\u043e \u0434\u043b\u044f \u0441\u0432\u043e\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0430\u044f \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<pre><code class=\"sql\">create virtual table emails using fts5(sender, body); SELECT * FROM emails WHERE emails = 'fts5'; -- sender \u0438\u043b\u0438 body \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 fts5 <\/code><\/pre>\n<p>  <\/p>\n<h3>\u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f<\/h3>\n<p>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 SQLite \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u0447\u0435\u0440\u0435\u0437 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438. \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445 \u0443\u0436\u0435 \u0431\u044b\u043b\u0438 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u044b \u0432\u044b\u0448\u0435 \u2014 <a href=\"https:\/\/www.sqlite.org\/src\/file?name=ext\/misc\/json1.c&amp;ci=tip\" rel=\"nofollow\">json1<\/a> \u0438 <a href=\"https:\/\/www.sqlite.org\/src\/dir?ci=tip&amp;name=ext\/fts5\" rel=\"nofollow\">fts<\/a>.<\/p>\n<p>  \u0420\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 (\u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u044b\u0445, \u043a\u0430\u043a, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>crc32<\/code>, \u043d\u043e \u0438 <a href=\"https:\/\/sqlite.org\/appfunc.html\" rel=\"nofollow\">\u0430\u0433\u0440\u0435\u0433\u0438\u0440\u0443\u044e\u0449\u0438\u0445<\/a> \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 <a href=\"https:\/\/sqlite.org\/windowfunctions.html#udfwinfunc\" rel=\"nofollow\">\u043e\u043a\u043e\u043d\u043d\u044b\u0445<\/a>), \u0442\u0430\u043a \u0438 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446. \u0412\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u2014 \u044d\u0442\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0432 \u0431\u0430\u0437\u0435, \u043d\u043e \u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0435 <a href=\"https:\/\/www.sqlite.org\/vtab.html#tabfunc2\" rel=\"nofollow\">\u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u044e\u0442\u0441\u044f<\/a> \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438, \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f<\/p>\n<pre><code class=\"sql\">create virtual table temp.tab1 using csv(filename='thefile.csv'); select * from tab1;<\/code><\/pre>\n<p>  \u0414\u0440\u0443\u0433\u0438\u0435 \u0436\u0435, \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435 <a href=\"https:\/\/www.sqlite.org\/vtab.html#tabfunc2\" rel=\"nofollow\">table-valued<\/a>, \u043c\u043e\u0433\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0440\u0430\u0437\u0443<\/p>\n<pre><code class=\"sql\">select value from generate_series(5, 100, 5);<\/code><\/pre>\n<p>.<br \/>  \u0427\u0430\u0441\u0442\u044c \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0430 <a href=\"https:\/\/sqlite.org\/vtablist.html\" rel=\"nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<p>  \u041e\u0434\u043d\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0442\u0430\u043a \u0438 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, json1 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 13 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u044b\u0445 \u0438 2 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0434\u0432\u0435 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b <code>json_each<\/code> \u0438 <code>json_tree<\/code>. \u0427\u0442\u043e\u0431\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0438\u043c\u0435\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u0437\u043d\u0430\u043d\u0438\u044f \u0421 \u0438 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c \u043a\u043e\u0434 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 <a href=\"https:\/\/www.sqlite.org\/src\/dir?ci=tip&amp;name=ext\/misc\" rel=\"nofollow\">\u0438\u0437 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u0430\u0440\u0438\u044f SQLite<\/a>. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0441\u0432\u043e\u0438\u0445 \u0432\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435 (\u0432\u0438\u0434\u0438\u043c\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0445 \u043c\u0430\u043b\u043e). \u0422\u0443\u0442 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0443\u044e \u043a\u043d\u0438\u0433\u0443 <a href=\"https:\/\/www.oreilly.com\/library\/view\/using-sqlite\/9781449394592\/\" rel=\"nofollow\">Using SQLite by Jay A. Kreibich<\/a>, \u0441\u0442\u0430\u0442\u044c\u044e <a href=\"https:\/\/www.drdobbs.com\/database\/query-anything-with-sqlite\/202802959\" rel=\"nofollow\">Michael Owens<\/a>, \u0448\u0430\u0431\u043b\u043e\u043d <a href=\"https:\/\/www.sqlite.org\/src\/file?name=ext\/misc\/templatevtab.c&amp;ci=tip\" rel=\"nofollow\">\u0438\u0437 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u0430\u0440\u0438\u044f<\/a> \u0438 \u043a\u043e\u0434 <a href=\"https:\/\/www.sqlite.org\/src\/file?name=ext\/misc\/series.c&amp;ci=tip\" rel=\"nofollow\">generate_series<\/a>, \u043a\u0430\u043a table-valued \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<p>  \u041f\u043e\u043c\u0438\u043c\u043e \u044d\u0442\u043e\u0433\u043e, \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u043d\u044b\u0435 \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0432\u0435\u0449\u0438, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0444\u0430\u0439\u043b\u043e\u0432\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430, \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u044e\u0449\u0438\u0435 \u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u044c. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c <a href=\"https:\/\/www.sqlite.org\/vfs.html\" rel=\"nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<h3>\u0420\u0430\u0437\u043d\u043e\u0435<\/h3>\n<ul>\n<li>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <code>'<\/code> (\u043e\u0434\u0438\u043d\u0430\u0440\u043d\u0430\u044f \u043a\u0430\u0432\u044b\u0447\u043a\u0430) \u0434\u043b\u044f \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0445 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442 \u0438 <code>&quot;<\/code> (\u0434\u0432\u043e\u0439\u043d\u0430\u044f \u043a\u0430\u0432\u044b\u0447\u043a\u0430) \u0434\u043b\u044f \u0438\u043c\u0435\u043d \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0438 \u0442\u0430\u0431\u043b\u0438\u0446.<\/li>\n<li>\u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043f\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0435 tab1 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\n<pre><code class=\"sql\">-- \u0412 main \u0441\u0445\u0435\u043c\u0435 select * from pragma_table_info('tab1'); -- \u0412 temp \u0441\u0445\u0435\u043c\u0435 \u0438\u043b\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u043e\u0439 (attach) \u0431\u0430\u0437\u0435 select * from pragma_table_info('tab1') where schema = 'temp'<\/code><\/pre>\n<\/li>\n<li>\u0423 SQLite \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0439 <a href=\"https:\/\/sqlite.org\/forum\/forummain\" rel=\"nofollow\">\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0444\u043e\u0440\u0443\u043c<\/a>, \u0433\u0434\u0435 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u0435\u0442 \u0438 \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u044c SQLite \u2014 Richard Hipp, \u0438 \u0433\u0434\u0435 \u043c\u043e\u0436\u043d\u043e \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e \u0431\u0430\u0433\u0435.   <\/li>\n<li>\u0420\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u044b SQLite: <a href=\"https:\/\/sqlitestudio.pl\/\" rel=\"nofollow\">SQLite Studio<\/a>, <a href=\"https:\/\/sqlitebrowser.org\/\" rel=\"nofollow\">DB Browser for SQLite<\/a> \u0438 (\u0440\u0435\u043a\u043b\u0430\u043c\u0430!) <a href=\"https:\/\/github.com\/little-brother\/sqlite-gui\" rel=\"nofollow\">sqlite-gui<\/a> (\u0442\u043e\u043b\u044c\u043a\u043e Windows).  <\/li>\n<\/ul>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/528882\/\"> https:\/\/habr.com\/ru\/post\/528882\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\">\u0415\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 SQLite, \u043d\u043e \u043d\u0435 \u0441\u043b\u0435\u0434\u0438\u0442\u0435 <a href=\"https:\/\/www.sqlite.org\/changes.html\" rel=\"nofollow\">\u0437\u0430 \u0435\u0433\u043e \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435\u043c<\/a>, \u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0435\u0449\u0438, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u0434 \u043f\u0440\u043e\u0449\u0435, \u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u043f\u0440\u043e\u0448\u043b\u0438 \u043d\u0435\u0437\u0430\u043c\u0435\u0447\u0435\u043d\u043d\u044b\u043c\u0438. \u041f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0432\u0430\u0436\u043d\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-313478","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/313478","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=313478"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/313478\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=313478"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=313478"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=313478"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}