如何枚举sqlite中的所有表及其字段??
我有一份sqlite数据库文件,但不知道里面的表名,如何枚举出所有的表名以及其字段名??
关键是sqlite的sql语句如何写?我试了一些sql语句不行,特来求助。
字段名 则无法象表名一样从数据库系统表中直接获得。你只能打开每个表后,遍历其字段。比如使用ADO.recordset打开表后,通过fields.name 得到列名和其它信息(字段定义类型,长度)
或者 在sqlite 中用 .
.schema ?TABLE? Show the CREATE statements
显示表结构
SQL code:
sqlite> .schema t1
CREATE TABLE t1 (id int primary key, col1 int,col2 int);
sqlite>
sqlite> select sql from sqlite_master where name='t1' and type='table';
sql
CREATE TABLE t1 (id int primary key, col1 int,col2 int)
sqlite>
sqlite> select * from t1;
id|col1|col2
1|1|1
2|2|2
3|3|3
PRAGMA table_info(表名) 可以得到字段信息
相关问答:
如题,没有主键,我只要删除前N条记录。n数值大概在千万级别的。
没有主键
有没有其它可供排序的字段?
SQL code:
delete from tb where id in (select top n id from tb)
引用
没有主键
......
大家好,请问各位大虾,谁有SQLITE存图片路径的代码或例子啊,请帮忙给小弟发一个,tiandaliubin@163.com 真的很急啊。先谢谢了。
http://www.sqlite.org/cvstrac/wiki?p=SqliteWrappers
引用
http://www.sql ......
Java code:
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs=stmt.executeQuery("select * from table");//报错的行
rs.last()
用rs.last( ......
delphi连接Sqlite 增删改查例子
数据库已经连通了, 插入会报错,no query specified
with dm.ASQLite3Query1 do
begin
dm.ASQLite3Query1.Close;
dm.ASQLite3 ......