如何枚举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(表名) 可以得到字段信息
相关问答:
C# code:
public static bool UpdateFriendUrl(int id, string cnName, string jpName, string logoUrl, string site, int order)
{
string sql = "update FriendUrl set SiteNameCN=@SiteNameC ......
C# code:
System.Data.SQLite.SQLiteConnection conn = new SQLiteConnection(@"acs.db");
try
{
conn.Open();
}
......
在 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 ......