更新时间:2023-11-30 12:42:16
您可以使用 IDENTIFIER
关键字.
You can achieve this using SQL variables and the IDENTIFIER
keyword.
下面是一个将当前日期添加到表名的示例:
Here's an example that adds the current date into the table-name:
SET table_name=(SELECT 'someNewTable_' || TO_VARCHAR(CURRENT_DATE(), 'YYYYMMDD'));
CREATE TABLE IDENTIFIER($table_name) (col STRING);
对于使用IDENTIFIER
关键字不足的更复杂的任务,您还可以使用存储过程
For more complicated tasks where using IDENTIFIER
keyword is inadequate, you can also use stored procedures as shown in this answer.