mysql - 为什么sqlite中显示 "no such column"却有 `pragma`?

标签 mysql sql sqlite command-line

我在 sqlite 中有一个表,我可以在 sqlite 命令行中显示列,如下所示:

pragma table_info(new_table);

它打印以下内容:

|0|col1,col2,col3,col4|TEXT|0||0

然后我尝试像这样打印该列:

select new_table.col1 from new_table;
Error:no such column:  new_table.col1

我尝试在 csv 中的每一列周围添加引号,但无济于事:

"col1","col2","col3","col4"
3,4,2,5
5,2,3,6

当我尝试导入此 csv (.import Something.csv new_table) 时,出现错误:

unescaped " character

有什么办法可以解决这个问题呢?

谢谢。

最佳答案

pragma table_info 输出中的

|0|col1,col2,col3,col4|TEXT|0||0 表示列名称为 col1,col2 ,col3,col4。没有名为 col1 的列。检查创建表的 SQL - 可能有例如列周围的 "" 双引号放错了位置。

<小时/>

编辑:要使 sqlite3 shell .import 处理您的数据,请添加

.separator ","

.import之前。

关于mysql - 为什么sqlite中显示 "no such column"却有 `pragma`?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31794344/

相关文章:

MYSQL WHERE-IN 子查询永远运行

mysql - 将两个mysql表合并成第三个表

mysql - 使用 mysql 的存储引擎中的存储 28 错误

sql - 从结果中选择最大日期行

mysql - 如何获取不重复的员工/经理表

php - 征信系统如何防范欺诈?

android - 更新时间戳时出现 Sqliteexception?

c - 如何将数据库附加到可执行文件

mysql - 当我使用 SQL 更新时,如果字段为空,则会将该值更改为数据库中的空值

Android Persistence room : "Cannot figure out how to read this field from a cursor"