如何枚举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)
引用
没有主键
......
电话本匹配查询,希望一条语句搞定
假设号码本(numtable)如下:
号码(num) 联系人 (relationname)
10086 移 ......
我现在想按照字段 DAY 和 NAME 来查询,我想实现:比如,在一个输入框里输入 “2009-10-12张三”,可以查询出字段DAY和NAME的组合符合输入的那项。
一般好像是把两个条件分开写,where DAY= and NAME= 现在我想让 ......
在 SQL SERVER 中的语句 是:
SELECT
(ROW_NUMBER() OVER (ORDER BY Name) - 1) / 4 + 1 AS TitleRow,
(ROW_NUMBER() OVER (ORDER BY Name) - 1) % 4 + 1 AS Title ......