Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

CREATE TABLE – Concatenating a variable with a string to name the new table

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading