/* psqlの操作方法の基本の基本 C:\Users\yrl-user>psql -h localhost -U postgres postgres=# \l postgres=# \connect blogapp(データベース名) blogapp=# \dt blogapp=# \d users(テーブル名) blogapp=# select * from users; /* 検索の基本形 */ 分からなくなったら、ここ(PostgreSQL入門)で再履修 https://dotinstall.com/lessons/basic_postgresql /* データの型 数値:integer(int), real, serial 文字:char(5), varchar(255),text 真偽: boolean, TRUE, FALSE t f 日付: date, time, timestamp 制約 not null unique check default primary key(not null, unique) */ create table users ( id serial primary key, name varchar(255), score real, team varchar(255) ); insert into users (name, score, team) values ('taguchi', 5.5, 'red'), ('fkoji', 8.3, 'blue'), ('dotinstall', 2.2, 'blue'), ('sakaki', 5.0, 'green'), ('sasaki', 4.6, 'red'), ('kimura', 4.7, 'green'); create table posts ( id serial primary key, user_id int not null, title varchar(255) not null, body text not null ); insert into posts (user_id, title, body) values (1, 'title1', 'body1'), (1, 'title2', 'body2'), (2, 'title3', 'body3'), (5, 'title4', 'body4'), (4, 'title5', 'body4');