I have seen many explanations about SELECT INTO in the oracle clause. I found a difference in applying SELECT INTO in Oracle and other SQL databases. In Oracle, the SELECT INTO statement retrieves values from one or more database tables (as the SQL SELECT statement does) and stores them in variables (which the SQL SELECT statement does not do). Whereas in Postgres, SELECT INTO creates a new table from the results of a query.
I want to apply/implement such a thing in Postgres. What is the appropriate command or statement there?
Here is my Oracle query:
SELECT COUNT(1)
INTO ada
FROM atk_history_qty
WHERE tgl BETWEEN TO_DATE ('2014/02/01', 'yyyy/mm/dd')
AND TO_DATE ('2014/02/28', 'yyyy/mm/dd');
count(1)is faster thancount(*). In fact in Postgrescount(1)is actually slightly slower. – Jan 17 '23 at 10:40count(1)is fractionally slower in Oracle as well, as the parser has to convert it intocount(*)and that has to take a couple of cpu cycles. – William Robertson Jan 22 '23 at 19:26