postgresql 命令行读取sql

1.

C:\WINDOWS\system32>psql -U postgres -d postgres
psql (9.6.5)
"help" でヘルプを表示します.

postgres=# \encoding
SJIS
postgres=#
 

postgresql 命令行读取sql

2.SJIS形式保存下面的语句

/*
テーブルの作成とデータの追加
2020/04/19
*/

--テーブルの作成
create table friends(id integer, name varchar(10));


--データの追加
insert into friends values(1,'Tom');
insert into friends values(2,'Jim');
insert into friends values(3,'Lily');

postgresql 命令行读取sql

3.


C:\WINDOWS\system32>psql -U postgres -d postgres
psql (9.6.5)
"help" でヘルプを表示します.

postgres=# \i 'c:/tmp/test.sql'

 

 

postgresql 命令行读取sql

 

4.

postgres=# select * from friends;

postgresql 命令行读取sql