如何在PostgreSQL中运行临时脚本? [英] How to run an ad-hoc script in PostgreSQL?

查看:84
本文介绍了如何在PostgreSQL中运行临时脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图在PostgreSQL 9.2中运行它:

I'm trying to run this in PostgreSQL 9.2:

RAISE NOTICE 'hello, world!';

服务器说:

Error : ERROR:  syntax error at or near "RAISE"
LINE 1: RAISE NOTICE 'hello, world!'
        ^

为什么?

推荐答案

使用匿名< href = http://www.postgresql.org/docs/current/static/sql-do.html>代码块:

DO language plpgsql $$
BEGIN
  RAISE NOTICE 'hello, world!';
END
$$;

使用引用变量

RAISE NOTICE '%', variable_name;

这篇关于如何在PostgreSQL中运行临时脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆