【pg】shell写入数据

todo:

postgresql,自动灌入数据

1)ssh到rip

2)su postgres

3)执行自动灌入数据

sh  pg_create.sh   & 

 

 

pg_create.sh 脚本内容如下

 

#!/bin/bash

 

export L=1000000

 
psql -c 'create database if not exists db1;'

psql -c 'l'

psql -c 'c db1;'
 

psql -c 'create table if not exists t1(id int, id2 timestamp);'

 

for ((i=0;i<$L;i++))

do

   psql -c 'insert into t1 values(1, now());'

done

 

psql -c 'select count(*) from t1;'

  

 

 

参考:https://www.cnblogs.com/setevn/p/8729324.html

大道至简
原文地址:https://www.cnblogs.com/liurong07/p/12461152.html