LuoYao666

--编写脚本文件

[postgres@localhost ~]$ cat test_2.sql
create table test_2(id int4);
insert into test_2 values (1);
insert into test_2 values (2);
insert into test_2 values (3);
insert into test_2 values (4);

导入数据(也可以指定库,用户),加上参数q之后可以不在显示具体信息

[postgres@localhost ~]$ psql -f test_2.sql
CREATE TABLE
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1

或者

[postgres@localhost ~]$ psql -q -f test_2.sql

psql -1 -f支持在一个事务中的脚本,要么所有sql执行成功,要么所有sql执行失败,文件所有sql回滚

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-22
  • 2022-01-01
  • 2022-01-01
  • 2021-10-02
  • 2022-12-23
猜你喜欢
  • 2022-01-01
  • 2022-12-23
  • 2022-12-23
  • 2021-07-11
  • 2021-06-22
  • 2022-12-23
  • 2021-09-23
相关资源
相似解决方案