我有一个表student
和一个视图annual_performance
。我正在创建如下的视图student_annual_performance
CREATE OR REPLACE VIEW student_annual_performance AS SELECT
s, ap
FROM student s INNER JOIN annual_performance ap ON s.id = ap.studentId;
在PostgreSQL中工作正常,但在H2内存数据库中出现以下错误
SQL状态:42S22错误代码:42122消息:找不到“ ap”列; SQL语句:
您使用了其他数据库中不存在的特定于PostgreSQL的神秘功能。在H2和大多数其他数据库中,不能使用表(视图)名称或其别名作为值表达式。
您可以在两个数据库中代替使用… AS SELECT (s.column1, s.column2, …) s, (ap.column1, ap.column2, …) ap FROM …
,其中column1
,column2
等是表student
和视图annual_performance
中的列的名称,以得到相同的结果。
您还可以使用… AS SELECT * FROM …
来获取单独列中的所有值。