开发者社区> 问答> 正文

在SQLIte3中,是否可以在单个数据库中连续读取/写入多个SQL表?

考虑以下数据库:

Name.db应该包含多个SQL表,例如:

SQL表的名称:John,Peter,Nolan

每个SQL表将包含数据:

例:

  ```js

Name of the SQL table: John

                        电话_没有地址城市

      ```js
Name of the SQL table:     Nolan

                   电话_没有地址城市
#include <stdio.h> /* needed for vsnprintf */
    #include <stdarg.h> /* needed for va_list */
    #include <stdlib.h> /* needed for malloc-free */
    #include <string.h>
    #include <sqlite3.h>

    char *sql = NULL;
    char *a[3] = {John, peter, Nolan};
    int rc, i;  

    /* Create or opens a database. */
    rc = sqlite3_open("test.db", &db);
    if (rc) 
    {
           fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));        
           return(0);
    }
    else 
    {
         fprintf(stderr, "Opened database successfully..NEW123\n");
    }

    for(i=0; i<=2;i++)
    {
       /* Creation of SQL table. */
     sql = "create table '%s' (Phone_No integer, Address varchar(255), City varchar(255));",a[i];                   

        rc = sqlite3_exec(db, sql, callback,0,&zErrMsg); 
        if (rc != SQLITE_OK)
        {
                printf("Error: %s:Unable to create the table\n", zErrMsg);  
        }
    }

在上面的代码中,我能够创建多个SQL表,但是我想知道是否可以连续读取/写入上面的SQL表(即,john,peter,Nolan)。

展开
收起
几许相思几点泪 2019-12-23 22:04:47 692 0
0 条回答
写回答
取消 提交回答
问答排行榜
最热
最新

相关电子书

更多
2022 DTCC-阿里云一站式数据库上云最佳实践 立即下载
云时代的数据库技术趋势 立即下载
超大型金融机构国产数据库全面迁移成功实践 立即下载