Home > Back-end >  CREATE TABLE - Concatenating a variable with a string to name the new table
CREATE TABLE - Concatenating a variable with a string to name the new table

Time:04-21

I want to create a tables concatenating a prefix with a given identifier. The prefix will change every time I create a new table with the same query.

I have tried a few variation of the following idea without success:

DEF  prefix_edms = 'z_edm';

CREATE TABLE CONCAT(&prefix_edms,'_TABLE_A') as
(
SELECT 'HolaPoho' from dual
);

Is there any way I can do this in Oracle?

CodePudding user response:

As it is SQL*Plus, you'd then

SQL> set ver off
SQL> def prefix_edms = 'z_edm'
SQL> create table &prefix_edms._table_a as select 'HolaPoho' name from dual;

Table created.

SQL> select * from z_edm_table_a;

NAME
--------
HolaPoho

SQL>
  • Related