如何在 SQLite 终端中选择奇怪的列名?
sqlite> select * from questions;
data_id data_text data_image parent_id data_order data_id:1 data_text:1
---------- ---------- ---------- ---------- ---------- ---------- -----------
23 google 5 5 favorites
你好,我正在测试查询。但我只想选择“data_text:1”列。
我不知道如何选择列。
sqlite> select * from questions;
data_id data_text data_image parent_id data_order data_id:1 data_text:1
---------- ---------- ---------- ---------- ---------- ---------- -----------
23 google 5 5 favorites
Hi, I'm testing query. But I want to select just the 'data_text:1' column.
I don't know how to select column.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
用双引号将列名称引起来:
SQLite 遵循 SQL-92 语法,其中双引号用于引用标识符(列/表名称)。单引号用于引用文字值,例如字符串
'I am a string!'
或X'ABCD'
(blob 数据)。快乐编码。
我建议简单的列名,不需要在 SQL 中加引号,并且不与保留字冲突,因为它使生活更轻松。
Surround the name of the column with double-quotes:
SQLite follows SQL-92 syntax where double quotes are used to quote identifiers (column/table names). Single quotes are used to quote literal values like strings
'I am a string!'
orX'ABCD'
(blob data).Happy coding.
I recommend simple column names that do not require to be quoted in SQL and do not clash with reserved words as it make life easier.
用 `` 将列名称括起来,
称为“反引号”,您通常会在键盘上的 TAB 上方和 1 左侧找到它。
或者,您可以通过组合获得它:(alt gr + 7)
Surround the name of the column with ``
Known as a 'backtick' you usually find it above TAB and left of 1 on keyboards.
Alternatively you can get it with the combination : (alt gr + 7)
用双引号 @pst 括住列名称
有助于在注释中对其进行解释。我在这里转述他的话:
Surround the name of the column with double-quotes
@pst helps to explain it in a comment. I'm paraphrasing him here: