PgSQl临时表创建及应用实例解析
创建前可先删除
droptabletmp0
创建临时表
select*intotemptabletmp0fromxxxcreateindexidx_tmp0_inner_cdontmp0(inner_cd);
查看临时表是否创建,返回0表示未创建,1为创建
selectcount(*)frompg_classwhererelname='tmp0'
或者用下面,下面语句在pg和mysql中都适用
CreateTableIfNotExiststemp.MyTable( xxxvarchar(20)Primarykey, thTimevarchar(20), namevarchar(20) )
同样可以用在删除表中:
DROPTABLEIfExiststemp.mjp_temp_update_log
应用例子:
SELECT ids, code, INTOTEMPTABLEtmp0 FROM TEMP.m_product_x WHERE TEMP.m_product_x.ids='' GROUPBY TEMP.m_product_x.code, TEMP.m_product_x.ids; CREATEINDEXidx_tmp0_inner_cdONtmp0(code); SELECT * FROM TEMP.m_product INNERJOINtmp0ONTEMP.m_product.code=tmp0.code WHERE TEMP.m_product.ids='' ORDERBY tmp0.xx, tmp0.ss; DROPTABLEtmp0;
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。