gpt4 book ai didi

sqlite - SQLite数据字典表和列

转载 作者:行者123 更新时间:2023-12-03 17:50:36 26 4
gpt4 key购买 nike

您能告诉我们SQLite数据字典中所有表和表列的名称吗?

更新:

我正在为正在开发的Basic4Android应用程序使用此信息。

这是我使用的实际编码段:

' Create the PeopleToVisit table which holds lookup data about each visit.
'-------------------------------------------------------------------------
If SQL.ExecQuerySingleResult( _
"SELECT count(name) FROM sqlite_master WHERE type='table' AND name='PeopleToVisit'") _
= 0 Then

ToastMessageShow("Creating the People to Visit table.", False)

' Create it now since it doesn't yet exist.
'------------------------------------------
SQL.ExecNonQuery("CREATE TABLE PeopleToVisit (" & _
"Id INTEGER PRIMARY KEY, " & _
"FirstName TEXT, " & _
"LastName TEXT, " & _
"Address1 TEXT, " & _
"Address2 TEXT, " & _
"City TEXT, " & _
"State TEXT, " & _
"Zip TEXT " & _
")")
End If

' New table columns for Version 1.2
'----------------------------------

' Coding for when new data columns need to be added to the database table.
'-------------------------------------------------------------------------
strCreateTableStatement = _
SQL.ExecQuerySingleResult("SELECT sql " & _
"FROM sqlite_master " & _
"WHERE Type = 'table' AND name = 'PeopleToVisit'")

' Check if the new columns are in the table.
'-------------------------------------------
If strCreateTableStatement.IndexOf("PrimaryPhone TEXT") = -1 Then

' We need to add the new columns to the table.
'---------------------------------------------
SQL.ExecNonQuery("ALTER TABLE PeopleToVisit ADD COLUMN PrimaryPhone TEXT")
SQL.ExecNonQuery("ALTER TABLE PeopleToVisit ADD COLUMN SecondaryPhone TEXT")
SQL.ExecNonQuery("ALTER TABLE PeopleToVisit ADD COLUMN Email TEXT")
SQL.ExecNonQuery("ALTER TABLE PeopleToVisit ADD COLUMN LastVisitNote TEXT")
End If

最佳答案

列出数据库中的所有表

SELECT name FROM sqlite_master WHERE type='table'


列出表中的所有列

pragma table_info(table_name)

关于sqlite - SQLite数据字典表和列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8287758/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com