易截截图软件、单文件、免安装、纯绿色、仅160KB

Sqlite实现默认时间为当前时间列的方法

    在SQL Server中,创建表格的时候,对于时间列有时候我们可以根据需要指定默认值为当前时间(也就是说记录生成的时候有默认的时间戳)。例如:
    create table log(
content varchar(256),
logtime datetime default getdate()
)
  
    然而在Sqlite中如何实现呢?查文档得知Sqlite中并没有getdate()函数,但其系统内置函数有datetime(),因此能不能按照下面的写法实现默认时间戳呢:
    create table log(
content varchar(256),
logtime datetime default datetime('now')
)
  
    答案是否定的,会提示语法错误。那么应该如何声明呢?如下所示:
    create table log(
content varchar(256),
logtime TIMESTAMP default CURRENT_TIMESTAMP
)
    
    这个可以达到效果,但是默认的时间是以格林尼治标准时间为基准的,因此在中国使用的话会正好早8个小时。为了解决这个问题,我们可以这样声明:
    create table log(
content varchar(256),
logtime TIMESTAMP default (datetime('now', 'localtime'))
)

    测试一下,一切正常:)


相关文档:

C#与Sqlite数据库操作实例

这是一个有关分页的实例,仅供参考(代码来自网络)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SQLite;
using System.Threading;
using System.Collections;
us ......

sqlce与sqlite数据库的比较

最近由于项目需要, 要在wince4.2, wince5.0, mobile三种机型上面做大数据量的查询,初步估计在50W-500W条记录之间。
由于以前做mobile5的数据库项目主要是采用C#来写,而且数据量也顶多几万条,所以,为了确保项目后期少走弯路,我特意做了一下移动数据库性能测试。下面是这周的工作记录。供大家参考。
一. 由于wince4.2 ......

SQLite Tutorial in PHP

 
SQLite Tutorial in PHP
SQLite is an SQL database manager used locally or on a website, and compatible
in particularly with PHP.
Summary
Installing SQLite and creating a database
.
Installing SQLite. Verifying the installation by creating a base.
Creating and using a SQLite tabl ......

sqlite关闭数据库,清除连接池

从网上找的例子,创建了一个数据库,追加了几条记录后,然后关闭数据库,然后准备向PDA下载数据库,发现文件竟然被占用了,已经关闭了数据库连接也无效,后来从网上看到需要清除连接池
using (SQLiteConnection cn = new SQLiteConnection("Data Source=" + strTempPath + "\\Smoke.db3;Pooling=true;FailIfMissing=false ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号