[Dev] Postgresqコマンドの学習steemCreated with Sketch.

in #japanese3 years ago

こんにちは、@yasuです。

postgresqlの復習です。

Postgresqバージョン確認
シェルpsql
psql -V
image.png

ログイン
シェルpsql
sudo -i -u postgres
psql
image.png

現在ログインしているロール(ユーザー)を確認する
シェルpsql
select current_user;
image.png

ユーザ追加
シェルpsql
前提 sudo -i -u postgres前提 sudo -i -u postgres
psql
createuser --interactivecreate user yasu CREATEDB CREATEROLE SUPERUSER;
create user yasu;
alter role yasu CREATEDB CREATEROLE SUPERUSER;
image.png

image.png
create role yasu LOGIN CREATEDB CREATEROLE SUPERUSER;
create role yasu;
alter role yasu LOGIN CREATEDB CREATEROLE SUPERUSER;
image.png

image.png
確認 \du

ユーザ削除
シェルpsql
dropuser yasudrop user yasu;
image.png
drop user if exists yasu;
drop role yasu;
image.png
drop role if exists yasu;
確認 \du

データベース作成
シェルpsql
createdb yasudbcreate database yasudb;
sudo -i -u postgres createdb yasudb
create database yasudb owner = yasu
image.png

データベース削除
シェルpsql
dropdb yasudbdrop database yasudb;
drop database if exists yasudb;
image.png
確認 \l
終了
シェルpsql
\q
image.png

Coin Marketplace

STEEM 0.04
TRX 0.32
JST 0.088
BTC 61553.95
ETH 1712.38
USDT 1.00
SBD 0.38