sqlite - 以编程方式确定主键

发布于 2024-09-16 03:50:03 字数 137 浏览 2 评论 0原文

我需要以编程方式确定给定 sqlite 表的主键字段(使用 sqlite api,而不是命令行)。

我可以获得表列表和列列表,但只能使用 Column_Type() 函数查看列类型。需要知道给定列是否是主键(如果使用复合键,则为主键的一部分)。

I need to programatically determine what the primary key field(s) are for a given sqlite table (using sqlite api, not command line).

I can get a list of tables and a list of columns, but only see the column type using the Column_Type() function. Need to know if a given column is the primary key (or part of the primary key if a compound key is used).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

阳光的暖冬 2024-09-23 03:50:03

看看 sqlite3_table_column_metadata

此例程返回有关特定列的特定列的元数据
使用传递的数据库连接句柄可访问数据库表
作为第一个函数参数。

Have a look at sqlite3_table_column_metadata:

This routine returns metadata about a specific column of a specific
database table accessible using the database connection handle passed
as the first function argument.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文