| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 7171 人关注过本帖
标题:sqlite 查询报语法错误,求大神分析
只看楼主 加入收藏
leichencsu
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2016-1-22
收藏
 问题点数:0 回复次数:2 
sqlite 查询报语法错误,求大神分析

创建一张表,
CREATE TABLE [realcircs]
([index] INTEGER  NOT NULL PRIMARY KEY AUTOINCREMENT,
[curr_date] string DEFAULT CURRENT_DATE NOT NULL,
[curr_time] string DEFAULT CURRENT_TIME NOT NULL,
[content] string DEFAULT '未填' NULL,[status] BOOLEAN DEFAULT 'false' NOT NULL)

然后写了个很简单的查询语句:
select * from realcircs where index = 1;
但是执行却是失败的:
SQL Error: near "index": syntax error  <select * from realcircs where index = 1;>
感觉也是符合sql语法的,不知为啥失败,求指导
2016-01-22 17:01
不懂才问
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:大草原
等 级:贵宾
威 望:29
帖 子:1503
专家分:6593
注 册:2010-7-5
收藏
得分:0 
sqlite> create table realcircs(
   ...> index integer not null primary key autoincrement,
   ...> curr_date string default current_date not null,
   ...> curr_time string default current_time not null,
   ...> content string default '未填' null,
   ...> status boolean default 'false' not null);
Error: near "index": syntax error
sqlite>

按着你的语法建立表  就提示错啦!


报告老师,我低头不是因为我在装低调,是你问的问题,我真的不会答,,,
2016-01-25 20:08
不懂才问
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:大草原
等 级:贵宾
威 望:29
帖 子:1503
专家分:6593
注 册:2010-7-5
收藏
得分:0 
关键问题   应该是index  应该是sqlite的命令关键字   不能当作表字段名

下面的语法   可以建立你要的表  

sqlite> create table realcircs3(
   ...> id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
   ...> curr_date char(15) default current_date not null,
   ...> content char(50) default '未填' not null,
   ...> status boolean default 'false' not null);
sqlite>

然后,这样就可以查询了
sqlite> select * from realcircs3 where id=1;
1|2016年1月25日|不知道填啥|true




报告老师,我低头不是因为我在装低调,是你问的问题,我真的不会答,,,
2016-01-25 20:46
快速回复:sqlite 查询报语法错误,求大神分析
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014830 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved