SoFunction
Updated on 2025-04-05

PgSQl temporary table creation and application example analysis

You can delete it before creation

drop table tmp0

Create a temporary table

select * into temp table tmp0 from xxx create index idx_tmp0_inner_cd on tmp0(inner_cd);

Check whether the temporary table is created, return 0 means not created, 1 is created

select count(*) from pg_class where relname = 'tmp0' 

Or use the following statement, both pg and mysql

Create Table If Not Exists (
xxx varchar (20) Primary key ,
thTime varchar (20) ,
name varchar (20)
)

It can also be used in the deletion table:

DROP TABLE If Exists temp.mjp_temp_update_log

Application example:

SELECT
  ids,
  code,
   INTO TEMP TABLE tmp0
FROM
  TEMP .m_product_x
WHERE
  TEMP .m_product_x.ids = ''
GROUP BY
  TEMP .m_product_x.code,
  TEMP .m_product_x.ids;
 
CREATE INDEX idx_tmp0_inner_cd ON tmp0 (code);
 
SELECT
*
FROM
  TEMP .m_product
INNER JOIN tmp0 ON TEMP .m_product.code = 
WHERE
  TEMP .m_product.ids = ''
ORDER BY
  ,
  ;
DROP TABLE tmp0;

The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.