我有一个 SQLite DB,其中只有一个大小约 1.5 MB 的表(实际上,总共有约 30 个表,但每个表都存储在一个单独的 .db 文件中)。
当我EXPLAIN QUERY PLAN用于任何表时,它显示全表扫描,据我所知这是不好的。但是,没有一个表有索引,而且选择查询的速度很快。
所以,我想知道我是应该在我们的表上添加一些索引还是保持它们原样?(现在,表最多有 5k 行,将来它们最多可能有 100k 行)。
附注。选择和插入的数量几乎相同..
所有的想法都受到高度赞赏。
我有下表,我试图将列“前缀”限制为 ASCII 字母字符。但是,在使用以下约束后,我仍然可以插入其他字符。为什么它不起作用?
CREATE TABLE test
(
id INTEGER NOT NULL PRIMARY KEY,
prefix TEXT NOT NULL,
CHECK(prefix NOT LIKE '%[^a-zA-Z]%')
)
Run Code Online (Sandbox Code Playgroud)
使用 Python 的 sqlite3 包和 DB Browser for SQLite
Oracle 允许主键具有重复值和空值。使用此功能并不是一个特别好的主意,但它意味着大多数开发人员认为主键的某些保证(非空、唯一)并不是真正的保证。
CREATE TABLE oracle_guarantees (
ID NUMBER(9,0),
NAME VARCHAR2(50 BYTE),
breed NVARCHAR2(100)
);
INSERT INTO oracle_guarantees VALUES (1, 'Fuzz Head', 'Tabby');
INSERT INTO oracle_guarantees VALUES (2, 'Fluffy Thing', 'Mix');
INSERT INTO oracle_guarantees VALUES (2, 'Fluffy Thing', 'Mix');
INSERT INTO oracle_guarantees VALUES (3, 'Tiger', 'Tabby');
INSERT INTO oracle_guarantees VALUES (4, 'Fur Beast', 'Bengal');
INSERT INTO oracle_guarantees VALUES (5, 'Karate', 'Japanese Bobtail');
INSERT INTO oracle_guarantees VALUES (6, 'Chairman Meow', 'Chinese Harlequin');
INSERT INTO oracle_guarantees VALUES (NULL, 'No Cat', 'No breed');
CREATE …Run Code Online (Sandbox Code Playgroud) 在 Linux 上安装 Zabbix 报告工具时出现以下配置错误。我已经尝试了两个版本(zabbix-2.0.9,zabbix-1.8.17),但遇到了同样的问题。
日志:
checking for macro __VA_ARGS__... yes
checking return type of signal handlers... void
checking for getloadavg... yes
checking for hstrerror... yes
checking for getenv... yes
checking for putenv... yes
checking for sigqueue... yes
checking for /proc filesystem... yes
checking for file /proc/stat... yes
checking for file /proc/cpuinfo... yes
checking for file /proc/0/psinfo... no
checking for file /proc/loadavg... yes
checking for file /proc/net/dev... yes
checking for long long format... no
checking for -rdynamic linking option... yes …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个具有 3 个状态的分类列:subA、subB 或两者都不是。
我正在使用 SqliteStudio 3.1.0、RHEL7.0。
我通过 Python/Pandas 将我的 csv 加载到 SQLITE 中。一切都按预期工作。
我在 GUI 中添加了约束:
"fullpath" TEXT Unique NOT NULL.
Run Code Online (Sandbox Code Playgroud)
我Sub在 SqiteStudio 中添加了列并在数据表中仔细检查。
alter table data add column Sub text(100)
Run Code Online (Sandbox Code Playgroud)
这有效,没有给出错误。然后我尝试:
insert into data(Sub)
select fullpath, case
when fullpath like "%subA%" then "subA"
when fullpath like "%subB%" then "subB"
else "Neither" end
from data
Run Code Online (Sandbox Code Playgroud)
我收到这个我不明白的错误。
[18:35:45] Error while executing SQL query on database 'test': 2 values for 1 columns
Run Code Online (Sandbox Code Playgroud) 我有一个 sqlite3 数据库,其中包含许多具有相同列的表。它是一个字典数据库,每个表名都是起始单词字母。
我想列出数据库中所有表中的单列,但找不到这样做的方法。
从 sqlite3 CLI 客户端,类似于:
sqlite3 -line my_db.db 'select my_column from *'
Run Code Online (Sandbox Code Playgroud)
当然上面的方法是行不通的。
sqlite3 在下面的查询中给出了“不明确的列名”错误。错误本身引用了一个可以想象的明确列名,将数据库标识为“sourcedb”,将表标识为“答案”,将字段标识为“标记”。为什么这个查询会触发错误?
sqlite> SELECT answers.*
FROM sourcedb.answers
INNER JOIN sourcedb.questions_tests
ON sourcedb.questions_tests.testskey = '121212eczema'
INNER JOIN sourcedb.answers_questions
ON sourcedb.questions_tests.questionskey = sourcedb.answers.questionskey
INNER JOIN sourcedb.answers
ON sourcedb.answers.answerskey = sourcedb.answers_questions.questionskey;
...> ...> ...> Error: ambiguous column name: sourcedb.answers.markup
Run Code Online (Sandbox Code Playgroud)
一些额外的细节...
sqlite> pragma table_info(answers);
0|markup|TEXT|0||0
1|identifier|TEXT|0||0
2|text|TEXT|0||0
3|answerskey|INTEGER|0||1
4|answertype|TEXT|0||0
5|ReadPerms||0||0
6|UpdatePerms||0||0
7|DeletePerms||0||0
sqlite> pragma database_list;
0|main|
2|sourcedb|/root/.ttest/database/sqlite/ttest-simple.sqlite
Run Code Online (Sandbox Code Playgroud) 如果我想从 postgresql 中获得最佳性能,那么下面的 sqlite pragma 相当于什么。
pragma synchronous = OFF;
pragma journal_mode = OFF;
pragma count_changes = OFF;
pragma temp_store = MEMORY;
Run Code Online (Sandbox Code Playgroud) 是否可以编写一个运行时间超过 5 秒的“简单”SQLite 查询。
我正在我的应用程序中编写一些单元测试来记录慢查询,为此,我想要一个我知道运行时间超过 5 或 10 秒的慢查询,(并创建一个警告来引发/记录) .
我正在考虑创建 10 个表,每个表中有 10 个条目,并对所有表进行连接选择。
但我不确定这是否是测试慢选择(而不是大返回集)的好方法。
我的计算机中有一系列 .db3 文件。它们就像 filename1.db3、filename2.db3、filename3.db3、filename4.db3 等等。
我可以用 sqlite 编辑器打开 filename1.db3。但是当我用 sqlite 编辑器打开 filename2.db3 文件时,sqlite 编辑器给了我错误,比如“格式不正确”。
我应该使用什么程序来打开所有这些 .db3 文件?提前致谢。
有没有办法做到这一点?我正在尝试做这样的事情:
SELECT x
FROM table
EXCEPT
WITH RECURSIVE ...();
Run Code Online (Sandbox Code Playgroud) sqlite ×11
performance ×2
postgresql ×2
errors ×1
except ×1
import ×1
index ×1
installation ×1
linux ×1
oracle ×1
regex ×1
reporting ×1
select ×1
sql-server ×1
unit-test ×1