2
0

【Windows】SQLiteのインストールからテーブル作成まで

Last updated at Posted at 2023-08-20

SQLiteの環境構築

SQLiteをインストール

1.png

  • ダウンロードファイルの配置
    ダウンロードしたzipファイルを展開後、今回は「C:\pg\sqlite\sqlite-tools-win32-x86-3420000」といったディレクトリ構成にしてsqlite実行ファイルを格納

2.png

データベースとテーブルの作成

  • データベースの作成
    • コマンドプロンプトからcdコマンドでダウンロードしたファイルの階層へ行き、 sqlite3 データベース名(任意) を実行して、SQLiteにデータベースを作成する
# sqlite実行ファイルが存在するフォルダに移動
cd C:\pg\sqlite\sqlite-tools-win32-x86-3420000

# データベースの作成(存在する場合は実行)
sqlite3 construct.db

3.png

  • dbファイルが生成されていることを確認

4.png

  • テーブルの作成
    • 以下のCREATE文を実行してテーブルを作成
# テーブルの作成
CREATE TABLE user_tb (
  id integer primary key, 
  name varchar(10)
);

5.png

  • .schema user_tbコマンドを実行して作成したテーブル情報を確認

6.png

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0