greenplum sql with 语句测试

原创
2022/02/16 14:17
阅读数 486

创建表

create table with_test (id int, name varchar(50), city varchar(50) primary key(id)) DISTRIBUTED BY (id);

insert with语句

INSERT INTO with_test 
WITH cte AS ( SELECT 1 AS id, 'green' AS NAME, 'BEN' AS city)
SELECT * FROM cte;

with select 语句

WITH cte1 
     AS (SELECT id FROM  with_test WHERE  NAME = 'green') 
SELECT * FROM  cte1;

delete with语句

DELETE FROM with_test 
WHERE  id = (WITH cte1 
    AS (SELECT id FROM with_test WHERE name = 'green') 
    SELECT * FROM cte1);
  

craete table with语句
CREATE TABLE with_test1 AS WITH cte1 AS
  (SELECT id FROM with_test WHERE name = 'green')
SELECT * FROM cte1 
DISTRIBUTED BY (id);

展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部