zoukankan      html  css  js  c++  java
  • postgresql shell脚本传递参数并执行sql脚本并

    参考:

    https://stackoverflow.com/questions/7389416/postgresql-how-to-pass-parameters-from-command-line

    https://blog.csdn.net/dazuiba008/article/details/79268537  (推荐)

    ######################################数据库表结构######################################
    # name character

    #######################################命令行执行#######################################
    # shell命令连接postgres数据库
    psql 数据库名 用户名 -v name="Hello World"
    # 接收变量 注意: 如果参数是字符串类型那么接收的时候必须是 :'变量名' 这种形式;如果是数字类则为 :变量名
    select * from tableName where name = :'name';

    #################################命令行执行sql脚本(查询操作)###########################
    # shell命令连接postgres数据库
    psql 数据库名 用户名 -v name="Hello World" -f test.sql
    # test.sql 注意: 如果参数是字符串类型那么接收的时候必须是 :'变量名' 这种形式;如果是数字类则为 :变量名
    select * from tableName where name = :'name';

    #################################命令行执行sql脚本(插入操作)###########################
    # shell命令连接postgres数据库
    psql 数据库名 用户名 -v name="Hello World" -f test.sql
    # test.sql 注意:1.tableName后面必须跟上全列名 2.如果参数是字符串类型那么接收的时候必须是 :'变量名' 这种形式;如果是数字类则为 :变量名
    insert into tableName(name) where name = :'name';

    字符串操作

          参考:https://www.postgresql.org/docs/9.1/static/functions-string.html  

  • 相关阅读:
    Install JDK In Ubuntu
    js初学—实现checkbox全选功能
    js初学—js全自定义单选框
    poj1679The Unique MST(次小生成树模板)
    hdu3486Interviewe(二分是错的)(ST算法RMQ + 判定上下界枚举)
    poj3974 Palindrome(Manacher最长回文)
    poj1734 Sightseeing trip(Floyd求无向图最小环)
    BZOJ1123 [POI2008]BLO(割点判断 + 点双联通缩点size)
    2.2 logistic回归
    神经网络的火热
  • 原文地址:https://www.cnblogs.com/lvlin241/p/9280395.html
Copyright © 2011-2022 走看看