「SQLite3」.tablesでテーブル一覧を取得する

操作方法
1..showでデータベースの情報を表示

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
C:\sqlite\sqlite3>sqlite3 arkgame.sqlite3
SQLite version 3.36.0 2021-06-18 18:36:39
Enter ".help" for usage hints.
sqlite> .show
echo: off
eqp: off
explain: auto
headers: off
mode: list
nullvalue: ""
output: stdout
colseparator: "|"
rowseparator: "\n"
stats: off
width:
filename: arkgame.sqlite3
C:\sqlite\sqlite3>sqlite3 arkgame.sqlite3 SQLite version 3.36.0 2021-06-18 18:36:39 Enter ".help" for usage hints. sqlite> .show echo: off eqp: off explain: auto headers: off mode: list nullvalue: "" output: stdout colseparator: "|" rowseparator: "\n" stats: off width: filename: arkgame.sqlite3
C:\sqlite\sqlite3>sqlite3 arkgame.sqlite3
SQLite version 3.36.0 2021-06-18 18:36:39
Enter ".help" for usage hints.
sqlite> .show
        echo: off
         eqp: off
     explain: auto
     headers: off
        mode: list
   nullvalue: ""
      output: stdout
colseparator: "|"
rowseparator: "\n"
       stats: off
       width:
    filename: arkgame.sqlite3

2.テーブルの一覧を取得

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
方法1
sqlite> .tables
usertbl
方法2
sqlite> .table
usertbl
方法3
sqlite> select name from sqlite_master where type = 'table';
usertbl
方法1 sqlite> .tables usertbl 方法2 sqlite> .table usertbl 方法3 sqlite> select name from sqlite_master where type = 'table'; usertbl
方法1
sqlite> .tables
usertbl

方法2
sqlite> .table
usertbl

方法3
sqlite> select name from sqlite_master where type = 'table';
usertbl

3.テーブルの作成SQL文を確認

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sqlite> .schema usertbl
CREATE TABLE usertbl(userid,name,addr);
sqlite> .schema usertbl CREATE TABLE usertbl(userid,name,addr);
sqlite> .schema usertbl
CREATE TABLE usertbl(userid,name,addr);

 

SQLite

Posted by arkgame