0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

PostgreSQLの基本中の基本コマンド

Last updated at Posted at 2022-07-15

はじめに

日常、よく使うpostgreSQLのコマンドをメモしました。
下記のコマンドをわかれば、一応仕事ができると思います。

postsqlの基本コマンド

ログイン/ログアウト

ログイン

$ psql -U ユーザ

ログアウト

# ¥q

データベース操作

データベース一覧を表示

# ¥l

データベースを新規作成

# create database 新規データベース名;

データベースを削除

# drop database データベース名;

データベースに操作

# ¥c データベース名;

テーブル操作

テーブル一覧を表示

# ¥dt

テーブルを作成

# create table 新規テーブル名;

テーブルを削除

# drop table テーブル名;

データ操作

データを新規追加

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

データを削除

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

データを編集

# UPDATE テーブル名 SET 列名=値 WHERE 条件;

データを検索

# SELECT * FROM テーブル名 WHERE 条件;
or
# SELECT 列名 FROM テーブル名 WHERE 条件;

dumpについて

dump取得

$ pg_dump -U ユーザー名 -d データベース名 > ダンプ名.dump

dump導入

$ psql -U ユーザー名 -d データベース名 < ダンプ名.dump
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?