ユーザ用ツール

サイト用ツール


powershell:sqlite_table_list

SQLiteでテーブルリストを表示する

一つ上へ

# SQLite の DLL を読み込み
Add-Type -Path ".\System.Data.SQLite.dll"
 
# SQLite データベースファイルのパス
$dbPath = ".\test.db"
 
# 接続文字列
$connectionString = "Data Source=$dbPath;Version=3;"
 
# 接続を開く
$connection = New-Object System.Data.SQLite.SQLiteConnection($connectionString)
$connection.Open()
 
# SQL: SQLite の内部テーブル sqlite_master からテーブル名を取得
$command = $connection.CreateCommand()
$command.CommandText = "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;"
 
# 実行
$reader = $command.ExecuteReader()
Write-Host "=== テーブル一覧 ==="
while ($reader.Read()) {
    Write-Host $reader["name"]
}
 
# 後処理
$reader.Close()
$connection.Close()
powershell/sqlite_table_list.txt · 最終更新: 2025/08/26 23:13 by mikoto