DO $$ DECLARE myvar integer; BEGIN SELECT 5 INTO myvar; DROP TABLE IF EXISTS tmp_table; CREATE TABLE tmp_table AS SELECT * FROM yourtable WHERE id = myvar; END $$; SELECT * FROM tmp_table;
posted on 2022-08-22 15:38 空明流光 阅读(65) 评论(0) 编辑 收藏 举报