postgresql是否具有谓词的最大数量?

时间:2014-05-02 14:32:12

标签: sql postgresql

我编写了一个非常长的查询,它在WHERE子句中有超过100个谓词,但是当我将它传递到POSTGRESQL环境时,它会在where子句中丢失一些AND。如果我删除了一些谓词,结果是正确的,这是因为where子句中有最大数量的AND吗?谢谢。

这是我的问题:

SELECT
student12.id,
student11.id,
student10.id,
student9.id ,
student8.id ,
student7.id ,
student6.id ,
student5.id ,
student4.id ,
student3.id ,
student2.id ,
student1.id 
FROM
student student12,
student student11,
student student10,
student student9,
student student8,
student student7,
student student6,
student student5,
student student4,
student student3,
student student2,
student student1
WHERE
student1.id<>student12.id and
student2.id<>student3.id and 
student2.id<>student4.id and 
student2.id<>student5.id and 
student2.id<>student6.id and 
student2.id<>student7.id and 
student2.id<>student8.id and 
student2.id<>student9.id and
student2.id<>student10.id and
student2.id<>student11.id and
student2.id<>student12.id and
student3.id<>student4.id and 
student3.id<>student5.id and 
student3.id<>student6.id and 
student3.id<>student7.id and 
student3.id<>student8.id and 
student3.id<>student9.id and
student3.id<>student10.id and
student3.id<>student11.id and
student3.id<>student12.id and
student4.id<>student5.id and 
student4.id<>student6.id and 
student4.id<>student7.id and 
student4.id<>student8.id and 
student4.id<>student9.id and
student4.id<>student10.id and
student4.id<>student11.id and
student4.id<>student12.id and
student5.id<>student6.id and 
student5.id<>student7.id and 
student5.id<>student8.id and 
student5.id<>student9.id and
student5.id<>student10.id and
student5.id<>student11.id and
student5.id<>student12.id and
student6.id<>student7.id and 
student6.id<>student8.id and 
student6.id<>student9.id and
student6.id<>student10.id and
student6.id<>student11.id and
student6.id<>student12.id and
student7.id<>student8.id and 
student7.id<>student9.id and
student7.id<>student10.id and
student7.id<>student11.id and
student7.id<>student12.id and
student8.id<>student9.id and
student8.id<>student10.id and
student8.id<>student11.id and
student8.id<>student12.id and
student9.id<>student10.id and
student9.id<>student11.id and
student9.id<>student12.id and
student10.id<>student11.id and
student10.id<>student12.id and
student11.id<>student12.id and

student1.class2=student2.class2 AND
student1.class2=student3.class1 AND
student1.class2=student4.class1 AND
student1.class1=student5.class1 AND
student1.class1=student6.class1 AND
student2.class2=student3.class1 AND
student2.class2=student4.class1 AND
student2.class1=student6.class2 AND
student2.class1=student8.class2 AND
student2.class1=student10.class2 AND
student2.class1=student12.class2 AND
student3.class1=student4.class1 AND
student3.class2=student11.class1 AND
student3.class2=student12.class1 AND
student4.class2=student7.class2 AND
student4.class2=student9.class2 AND
student4.class2=student11.class2 AND
student5.class1=student6.class1 AND
student5.class2=student8.class1 AND
student6.class2=student8.class2 AND
student6.class2=student10.class2 AND
student6.class2=student12.class2 AND
student7.class2=student9.class2 AND
student7.class2=student11.class2 AND
student8.class2=student10.class2 AND
student8.class2=student12.class2 AND
student9.class2=student11.class2 AND
student10.class2=student12.class2 AND
student11.class1=student12.class1 and
student1.sex=1 AND
student2.sex=2 AND
student3.sex=1 AND
student4.sex=2 AND
student5.sex=1 AND
student6.sex=1 AND
student7.sex=1 AND
student8.sex=1 AND
student9.sex=1 AND
student10.sex=1 AND
student11.sex=1 AND
student12.sex=1 and
student1.id<>student2.id and 
student1.id<>student3.id and 
student1.id<>student4.id and 
student1.id<>student5.id and 
student1.id<>student6.id and 
student1.id<>student7.id and 
student1.id<>student8.id and 
student1.id<>student9.id and
student1.id<>student10.id and
student1.id<>student11.id;

,输出错误为

test-#  student1.id<>student7.id and 
test-#  student1.i
test-#  student1.id<>stude
test-#  student1.id<>stude
test-#  student1.id<>stude
ERROR:  syntax error at or near "student1"
LINE 132:  student1.id<>stude
       ^

1 个答案:

答案 0 :(得分:1)

我观察到将剪贴板中的大量数据粘贴到putty.exe会话中运行的psql会导致它出现乱码,大多数字符会被丢弃。

所以我不这样做,我首先将其粘贴到一个文件中,然后psql -f thefile.sql

据推测,这是psql程序使用的readline库,因为我可以在putty会话中打开vi,将其置于插入模式,并将大量数据粘贴到其中,而不会删除字符。