Skip to content

Commit 3bde528

Browse files
authored
Update set-variable.md
1 parent 0896c08 commit 3bde528

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

docs/en/sql-reference/10-sql-commands/00-ddl/15-variable/set-variable.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ CREATE OR REPLACE TABLE monthly_sales(empid INT, amount INT, month TEXT) AS SELE
8282
-- Set a variable 't' to the name of the table 'monthly_sales'
8383
SET VARIABLE t = 'monthly_sales';
8484

85+
-- Access the variable directly
86+
SELECT $t;
87+
┌──────────────┐
88+
│ $t │
89+
├──────────────┤
90+
│ monthly_sales│
91+
└──────────────┘
92+
8593
-- Use IDENTIFIER to dynamically reference the table name stored in the variable 't'
8694
SELECT * FROM IDENTIFIER($t);
8795
┌───────┬────────┬───────┐

0 commit comments

Comments
 (0)