介绍
轻量级内存数据库
http://www.cnblogs.com/newstart/archive/2013/01/06/2847067.html
下载
http://www.sqlite.org/download.html (如sqlite-tools-win32-x86-3120100.zip)https://bitbucket.org/xerial/sqlite-jdbc/downloads (Java JDBC Library)
查看环境变量
.show
CREATE Database
http://www.tutorialspoint.com/sqlite/sqlite_create_database.htm
查看Database
.databases
数据类型
http://www.runoob.com/sqlite/sqlite-data-types.html
CREATE Table
http://www.runoob.com/sqlite/sqlite-create-table.html
e.g.create table t1(id NUMERIC, name TEXT);
查看Table
.tables
插入
http://www.runoob.com/sqlite/sqlite-insert.html
e.g.INSERT INTO t1 values(1,"a1");
查询
e.g.select * from t1;
更新
http://www.runoob.com/sqlite/sqlite-update.html
删除
http://www.runoob.com/sqlite/sqlite-delete.html
删除表
http://www.runoob.com/sqlite/sqlite-drop-table.html
退出
.quit
不支持
(1)分析函数如 ROW_NUMBER()
(2)本地变量定义(http://stackoverflow.com/questions/7739444/declare-variable-in-sqlite-and-use-it)
(3)http://www.sqlite.org/omitted.html
详细语法
http://www.cnblogs.com/helloandroid/articles/2150272.html
Java实现
import java.sql.*;
import org.sqlite.JDBC;
public class SqliteConn {
public Statement sqliteConn() {
Class.forName("org.sqlite.JDBC");
Connection conn = DriverManager.getConnection("jdbc:sqlite:zieckey.db");
Statement stat = conn.createStatement();
return stat;
}
public Statement sqliteClose(Connection conn) {
conn.close();
}
public void create(Statement stat) {
stat.executeUpdate( "create temp table tbl1(name varchar(20), salary int);" );
}
public void query(Statement stat) {
ResultSet rs = stat.executeQuery("select * from tbl1;");
while (rs.next()) {
System.out.print("name = " + rs.getString("name") + " ");
}
rs.close();
}
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}