postgresql - Postgres psql \i 似乎添加了一个分号
问题描述
我正在使用 postgres 教授 SQL 课程。我的一个学生发现了一些我不明白的东西。
\i
学生正在使用命令(即\i /temp/query.txt
:)将 ascii 文件中的多个查询提交给 psql
一些学生在最后一个命令后省略了分号 - 但他们仍然从文件中获得了有效的输出。
IEpsql
的行为是在文件末尾附加分号。
Postgres 是否接受分号或 EOF 作为命令的结尾 - 还是这里发生了其他事情?
(我在 Windows 上见过这个。还没有在 Unix 下看过) Postgres V 13.2
解决方案
从来源src/bin/psql/mainloop.c
:
/*
* If we have a non-semicolon-terminated query at the end of file, we
* process it unless the input source is interactive --- in that case it
* seems better to go ahead and quit. Also skip if this is an error exit.
*/
推荐阅读
- javascript - 如何使用 Angular 材料从后端获取标签作为名称属性?
- sql - 内连接:内连接不同表中的值之和,两边都没有命中时为0
- sql - SQL SERVER 为 2 Colmuns 两个不同的表添加检查约束
- python - 将迭代的值存储到张量 - Python、Numpy、pytorch
- php - 用于根据简码属性去除自定义字段标签的简码
- android - ExtendedFloatingActionButton - 图标重力设置为文本结束但图标不在中心时尖叫
- python - 按月和年对熊猫的数据框系列进行排序?
- mysql - 你可以将多值索引与范围扫描结合起来吗
- dialogflow-es - 有没有办法在用户被定向到网页后将用户重定向到谷歌助手操作中的同一会话
- android - 如何处理 Kotlin 中的递归和嵌套数据类