LoginSignup
2
0

More than 3 years have passed since last update.

よく使うSQL文 チートシート | SQLite編

Posted at

インストール

brew install sqlite3

データベースの作成と接続

sqlite3 データベースファイル名
sqlite3 test.db
sqlite3 test.sqlite3

テーブルを作成する

CREATE TABLE テーブル名(カラム名1 データ型, カラム名2 データ型);
create table personal2(id integer, title text);

テーブルのデータを取得

select * from テーブル名;

テーブルにカラムを追加する

ALTER TABLE テーブル名 ADD COLUMN カラム名[ データ型];

テーブルを削除

DROP TABLE テーブル名;

テーブルにデータを追加する

INSERT INTO テーブル名 VALUES(値1, 値2);

テーブルのデータを更新

UPDATE テーブル名 SET カラム名1 = 値1, カラム名2 = 値2 WHERE 条件式;

テーブルのデータを削除

DELETE FROM テーブル名 WHERE 条件式;

参考

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