SqlLite

sqlliteExpert下载

http://www.sqliteexpert.com/download.html3

Technorati 标签: c#+SqlLite

 

注意事项:

1、 ADO.NET Provider For SQLite 1.0.66版并不支持VS2005、只能在VS2008上用,使用VS2005的请用旧版。

其中安装目录下WM的dll需要把dll和lib文件名中的066去掉,否则在WM上不能使用。

2、SQLite的图形UI最好用SQLite Expert Personal,免费的,只不过英文版,支持UTF-8,不会乱码。sqliteadmin虽然支持中文界面,但数据容易乱码(不支持UTFF-8)。下载地址:http://www.sqliteexpert.com/download.html

3、SQLite的路径最好这样写(取数据库绝对路径):Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + \\sqliteTest.db" ,否则容易报错,因为SQLite是不支持相对路径数据库文件位置,只支持绝对路径,而且如果在指定路径没找到,SQLite还会在指定路径自建一个指定名称的数据库,同时报找不到指定表的错误,引起误解。

 

收集SQLite与Sql Server的语法差异 :

1.返回最后插入的标识值 
返回最后插入的标识值sql server用@@IDENTITY 
sqlite用标量函数LAST_INSERT_ROWID() 
返回通过当前的 SQLConnection 插入到数据库的最后一行的行标识符(生成的主键)。此值与 SQLConnection.lastInsertRowID 属性返回的值相同。

2.top n 
在sql server中返回前2行可以这样: 
select top 2 * from aa 
order by ids desc

sqlite中用LIMIT,语句如下: 
select * from aa 
order by ids desc 
LIMIT 2

3.GETDATE ( ) 
在sql server中GETDATE ( )返回当前系统日期和时间 
sqlite中没有

4.EXISTS语句 
sql server中判断插入(不存在ids=5的就插入) 
IF NOT EXISTS (select * from aa where ids=5) 
BEGIN 
insert into aa(nickname) 
select 't' 
END 
在sqlite中可以这样 
insert into aa(nickname) 
select 't' 
where not exists(select * from aa where ids=5)

5.嵌套事务 
sqlite仅允许单个活动的事务

6.RIGHT 和 FULL OUTER JOIN 
sqlite不支持 RIGHT OUTER JOIN 或 FULL OUTER JOIN

7.可更新的视图 
sqlite视图是只读的。不能对视图执行 DELETE、INSERT 或 UPDATE 语句,sql server是可以对视图 DELETE、INSERT 或 UPDATE

sqlite查询数据库中存在的所有表

From within a C/C++ program (or a script using Tcl/Ruby/Perl/Python bindings) you can get access to table and index names by doing a SELECT on a special table named "SQLITE_MASTER ". Every SQLite database has an SQLITE_MASTER table that defines the schema for the database.

SQL code

SELECT name FROM sqlite_master
WHERE type='table' ORDER BY name;

原文地址:https://www.cnblogs.com/myitm/p/2133497.html