New gameplay! How to "plant" a Christmas tree in PieCloudDB Database?

With the arrival of Christmas,

Many cities are also decorated with lights and colorful decorations.

Everywhere is full of festive atmosphere.

Of course Christmas is inseparable from the Christmas tree!

Put up Christmas decorations with your family,

Put small gifts prepared for each other under the tree,

A small sense of ceremony,

Full of romance and warmth.

today,

We will teach you how to use PieCloudDB Database

“Plant” this year’s Christmas tree!

Just like before planting a tree, you need to loosen the soil and dig a planting hole.

Before having a Christmas tree,

We also need to prepare the environment.

PieCloudDB Cloud Edition offers a free trial.

Open your browser,

Enter "app.pieclouddb.com";

After filling in the information on the registration page,

Click "Complete Registration",

You can try PieCloudDB cloud-native virtual data warehouse for free.

Enter the "Virtual Data Warehouse" page in the left menu bar.

Click "New Virtual Data Warehouse" and fill in "christmas_land".

After selecting the number of execution nodes, click "Confirm".

The new virtual data warehouse will be up and running automatically after creation.

When the status of the virtual data warehouse shows "Running",

You can use the computing resources.

Click "Data Insights" on the menu bar to enter the function page.

Click "File" to create a new SQL file;

The SQL file can be renamed "christmas_tree".

Click to open the SQL file.

Select the default database "openpie" and the virtual data warehouse "christmas_land",

The corresponding document contents will be displayed in the Query Editor.

if you still want

Explore more features of PieCloudDB cloud on cloud,

Welcome to click "Newbie Guide" at the bottom left of the menu bar.

Read the relevant documentation.

The preparation work has been completed.

Now we are ready to "plant" trees!

Enter this SQL in the "Query Editor":

WITH RECURSIVE christmas_tree(level, max_level) AS (
  SELECT 1, 7 -- 设置最大层数
  UNION ALL
  SELECT level + 1, max_level FROM christmas_tree WHERE level < max_level
)
SELECT 
 CASE
  WHEN level = max_level THEN lpad('', max_level - 1,  ' ') ||  repeat('|',1) || repeat('|',1)
  ELSE lpad('', max_level - level, ' ') || repeat('*', (level * 2) - 1) 
 END AS my_christmas_tree
FROM
  christmas_tree;

After execution, you can get a Christmas tree like this:

With a Christmas tree,

Now it’s time to hang various decorations on it!

Let’s run this SQL again:

WITH RECURSIVE christmas_tree(level, max_level) AS (  
  SELECT 1, 7 -- 设置最大层数  
  UNION ALL  
  SELECT level + 1, max_level FROM christmas_tree WHERE level < max_level  
)SELECT  
  CASE  
    WHEN level = 1 THEN lpad('', max_level - level, ' ') || repeat('*', 1) || repeat('.', (level * 2) - 2)  
    WHEN level = max_level THEN lpad('', (max_level - 1),  ' ') ||  repeat('|',1) || repeat('|',1)  
    ELSE lpad('', max_level - level, ' ') || repeat('*', 1) || repeat('.', (level * 2) - 2) || repeat('*', 1)  
  END AS tree  
FROM  
  christmas_tree;

The Christmas tree is covered with beautiful lights.

On winter nights, it warms the whole room.

If you are like me,

Already immersed in the joy of this festival,

You can enter this SQL:

CREATE OR REPLACE FUNCTION generate_tree_row(level INT, max_level INT)  
  RETURNS TEXT AS $$  
BEGIN  
  IF level = 1 THEN  
    RETURN lpad('', max_level - level, ' ') || repeat('*', 1) || repeat('.', (level * 2) - 2);  
  ELSIF level = max_level THEN  
    RETURN lpad('', (max_level - 1), ' ') || repeat('|', 1) || repeat('|', 1);  
  ELSE  
    RETURN lpad('', max_level - level, ' ') || repeat('*', 1) || repeat('.', (level * 2) - 2) || repeat('*', 1);  
  END IF;  
END;  
$$ LANGUAGE plpgsql;  
  
WITH RECURSIVE christmas_tree(level, max_level) AS (  
  SELECT 1, 7 -- 设置最大层数  
  UNION ALL  
  SELECT level + 1, max_level FROM christmas_tree WHERE level < max_level  
) SELECT  
  generate_tree_row(level, max_level) AS tree,  
  generate_tree_row(level, max_level) AS tree2,  
  generate_tree_row(level, max_level) AS tree3  
FROM  
  christmas_tree;

Now,

You get a Christmas tree forest!

The Christmas tree is “planted”!

May this little tree be filled with blessings and expectations for the future,

spend time with you

This Christmas is full of joy and peace,

Merry Christmas to everyone!

Broadcom announces the termination of the existing VMware partner program deepin-IDE version update, replacing the old look with a new look Zhou Hongyi: Hongmeng native will definitely succeed WAVE SUMMIT welcomes its tenth session, Wen Xinyiyan will have the latest disclosure! Yakult Company confirms that 95 G data was leaked The most popular license among programming languages ​​in 2023 "2023 China Open Source Developer Report" officially released Julia 1.10 officially released Fedora 40 plans to unify /usr/bin and /usr/sbin Rust 1.75.0 release
{{o.name}}
{{m.name}}

Guess you like

Origin my.oschina.net/u/5944765/blog/10388560