Question: how to create table variable in postgresql?
Answer: If I good remember you can not declare a variable as TABLE, there is no type TABLE in postgresql. – ... 
The functionality is the same as a temporary table. ... 
@ClodoaldoNeto in SQL Server there are two options for this use case: the first is to use a temp table just as in Postgres, the second is to use a table variable.