主题
读取表结构详细信息 - GetTableInfoDetail
函数简介
读取指定表的详细结构信息,返回包含列类型、长度、是否为主键等详细信息的字符串指针。
接口名称
GetTableInfoDetailDLL调用
c
long GetTableInfoDetail(long ola, long db, string tableName);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| ola | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| db | 长整数型 | 数据库连接句柄,由 OpenDatabase 接口生成。 |
| tableName | 字符串 | 表名称。 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
long db = ola.OpenDatabase("data/app.db", "");
if (db != 0) {
ola.ExecuteSql(db, "CREATE TABLE IF NOT EXISTS users(id INTEGER PRIMARY KEY, name TEXT, score REAL)");
std::string detail = ola.GetTableInfoDetail(db, "users");
ola.CloseDatabase(db);
}csharp
using OLAPlug;
var ola = new OLAPlugServer();
long db = ola.OpenDatabase("data/app.db", "");
if (db != 0)
{
ola.ExecuteSql(db, "CREATE TABLE IF NOT EXISTS users(id INTEGER PRIMARY KEY, name TEXT, score REAL)");
string detail = ola.GetTableInfoDetail(db, "users");
ola.CloseDatabase(db);
}python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
db = ola.OpenDatabase("data/app.db", "")
if db != 0:
ola.ExecuteSql(db, "CREATE TABLE IF NOT EXISTS users(id INTEGER PRIMARY KEY, name TEXT, score REAL)")
detail = ola.GetTableInfoDetail(db, "users")
ola.CloseDatabase(db)java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
long db = ola.OpenDatabase("data/app.db", "");
if (db != 0) {
ola.GetTableInfoDetail(db, "users");
ola.CloseDatabase(db);
}cpp
var ola = com("OlaPlug.OlaSoft")
var db = ola.OpenDatabase("data/app.db", "")
if(db) {
ola.GetTableInfoDetail(db, "users");
ola.CloseDatabase(db)
}vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
db = ola.OpenDatabase("data/app.db", "")
If db <> 0 Then
ola.GetTableInfoDetail(db, "users");
ola.CloseDatabase(db)
End Iftext
.局部变量 ola, OLAPlug
ola.创建 ()
db = ola.OpenDatabase (“data/app.db“, ““)
.如果真 (db ≠ 0)
ola.GetTableInfoDetail(db, "users");
ola.CloseDatabase (db)
.如果真结束aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var db = ola.OpenDatabase("data/app.db", "");
if(db){
ola.GetTableInfoDetail(db, "users");
ola.CloseDatabase(db);
}text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
长整数 db = ola.OpenDatabase("data/app.db", "")
如果真 (db ≠ 0)
{
ola.GetTableInfoDetail(db, "users");
ola.CloseDatabase(db)
}cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
long db = ola.OpenDatabase("data/app.db", "");
if (db != 0) {
ola.GetTableInfoDetail(db, "users");
ola.CloseDatabase(db);
}原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
long db = OpenDatabase(instance, "data/app.db", "");
if (db != 0) {
ola.ExecuteSql(db, "CREATE TABLE IF NOT EXISTS users(id INTEGER PRIMARY KEY, name TEXT, score REAL)");
std::string detail = ola.GetTableInfoDetail(db, "users");
CloseDatabase(instance, db);
}csharp
using System.Runtime.InteropServices;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
long instance = CreateCOLAPlugInterFace();
long db = OpenDatabase(instance, "data/app.db", "");
if (db != 0)
{
ola.ExecuteSql(db, "CREATE TABLE IF NOT EXISTS users(id INTEGER PRIMARY KEY, name TEXT, score REAL)");
string detail = ola.GetTableInfoDetail(db, "users");
CloseDatabase(instance, db);
}python
from ctypes import CDLL, c_int, c_int64
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
db = ola.OpenDatabase(instance, b"data/app.db", b"")
if db:
ola.ExecuteSql(db, "CREATE TABLE IF NOT EXISTS users(id INTEGER PRIMARY KEY, name TEXT, score REAL)")
detail = ola.GetTableInfoDetail(db, "users")
ola.CloseDatabase(instance, db)返回值
| 返回值 | 说明 |
|---|---|
| (返回值) | 包含表详细结构信息的字符串指针。如果操作失败,返回 0。使用完毕后需调用 FreeStringPtr 释放内存。 |
注意事项
| 项目 | 说明 |
|---|---|
与 GetTableInfo 相比 | 与 GetTableInfo 相比,此函数提供更详细的表结构信息,例如列的类型、长度、是否为主键、是否为外键等。 |
| 如果表不存在或操作失败 | 如果表不存在或操作失败,函数将返回 0。 |
