SQLite语法

Sqlite的语句基本上和mssql2005以上版本差不多。其中有一些不同。自我感觉sqlite的语句和mssqlserver2000更接近。

在这里只写不同的地方,

1.查询某个列表的前x条数据

  mssql:   select top x  * from Table

  sqlite:     select * from Table limit x

 

2.插入语句 和mysql类似,如果插入全部字段可以不写前面字段名称。

 mssql:   insert into Table(id,name)values(1,'jim')

 sqlite :  insert into table  values(1,'jim')

 

3.   字段自增长的,

     mssql:  设置字段  identity

     sqlite: 把字段设置不能为空的int类型,填充其他字段时,这个字段默认为自增长。

 

4. getdate ()
      mssql:  getdate()返回当前系统日期时间

      sqlite :  没有此函数

 

5.EXISTS语句

 如果ids =5的记录不存在,则向nickname字段插入 test数据


  mssql:   IF NOT EXISTS (select * from aa where ids=5)
              BEGIN
                     insert into table  (nickname) vlues ('test')
              END

sqlite:insert into aa(nickname)   select 'test'  where not exists(select * from aa where ids=5)

 

 

posted @ 2013-07-19 13:07  Mountains  阅读(314)  评论(0编辑  收藏  举报