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

SQLite用触发器来替代外键约束

SQLite用触发器来替代外键约束 CREATE TABLE [Category] (
  [Pkid] INTEGER  PRIMARY KEY AUTOINCREMENT NOT NULL,
  [CategoryName] NVARCHAR(32)  NOT NULL,
  [CategoryGuid] char(36)  UNIQUE NOT NULL,
  [CategoryDesc] nvarchar(256)  NULL
) CREATE TABLE [Product] (
  [Pkid] INTEGER  PRIMARY KEY AUTOINCREMENT NOT NULL,
  [CategoryPkid] INTEGER  NOT NULL,
  [ProductName] nvarchar(32)  NULL,
  [ProductPrice] NUMERIC(19,4) DEFAULT '0.00' NOT NULL
)   --Insert约束
CREATE TRIGGER FK_Product_CategoryPkid_Insert
BEFORE Insert ON Product
FOR EACH ROW BEGIN
  SELECT RAISE(ROLLBACK,'No this categoryPkid in category')
  WHERE (SELECT Pkid from Category WHERE Pkid = NEW.CategoryPkid) IS NULL;
END --Update约束
CREATE TRIGGER FK_Product_CategoryPkid_Update
BEFORE Update ON Product
FOR EACH ROW BEGIN
  SELECT RAISE(ROLLBACK,'No this categoryPkid in category')
  WHERE (SELECT Pkid from Category WHERE Pkid = NEW.CategoryPkid) IS NULL;
END


相关文档:

SQLite 3 杂记

1、如何得到最后插入项的自动增长ID值? 对应的C#代码段如下:

using (SQLiteConnection cn = new SQLiteConnection (“data source = Test.db”))
{
      cn.Open ();

      SQLiteCommand cmd = new SQLiteCommand ......

sqlite 数据库可视化查看修改分析工具sqlitebrowser


SQLite Database Browser
 
 
SQLite Database browser is a light GUI editor for SQLite databases, built on top of Qt. The main goal of the project is to allow non-technical users to create, modify and edit SQLite databases using a set of wizards and a spreadsheet-like interface.
Downlo ......

SQLite学习笔记(2)

再说在linux下建立.a 和点so
     到网站下载 sqlite-amalgamation-3.6.22.tar.gz 这个包,反正我下了sqlite3-3.6.22.bin.gz解压后编译不了。
     解压,运行
    #  ./configure --host=armv5l-linux --prefix=/opt/sqlite3/arm --enable-threadsafe. ......

java中使用sqlite数据库

sqlite数据库第三方java扩展包下载地址:http://www.zentus.com/sqlitejdbc/
有2个包,一个是nested(嵌入式的),一个是native(本地的)。
区别在于:nested 不需要额外的dll文件,但是速度慢。native需要一个额外的dll文件,速度很快。
 1.使用nested包:sqlitejdbc-v037-nested.jar
java代码:
java 代码
packa ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号