Skip to content

Instantly share code, notes, and snippets.

@tzmfreedom
Last active June 28, 2020 03:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tzmfreedom/caace5f6996bdac6cb55010869baeacf to your computer and use it in GitHub Desktop.
Save tzmfreedom/caace5f6996bdac6cb55010869baeacf to your computer and use it in GitHub Desktop.
機能 MySQL PostgreSQL sqlite3
起動 mysql -p -h ホスト名 -P ポート番号 -u ユーザ名 DB名 psql -h ホスト名 -p ポート番号 -U ユーザ名 DB名 sqlite3
データベース一覧 show databases; \l -
データベース切替 use DB名
\u DB名
\c DB名 -
テーブル一覧 show tables; \d
\dt
\d+
\dt+
.tables
テーブル定義確認 desc テーブル名; \d テーブル名 -
テーブルCREATE文確認 show create table テーブル名 pg_dump DB名 -U ユーザ名 -s -t テーブル名 .schema hoge
.schema
select * from sqlite_master where type='table' and name='hoge';
行表示の切り替え select * from t \G \x .mode line
今日の日付 curdate() current_date CURRENT_DATE
現在時刻 now() now() CURRENT_TIMESTAMP, CURRENT_TIME
日付変換(date to string) strftime('%Y-%m-%d', CURRENT_DATE)
日付変換(string to date) date('2017-12-05')
ヘルプ \h または ? ? .help
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment