plsql - Create a table in Oracle SQL If table does not exist using select and join -
the question common, facing 1 single issue in there not able find answer. have is, create table if table not exist. while creating table, need create select query(which result of join of 2 tables). "oracle sql developer" / "pl/sql".
the query using is:
declare count_matching_tbl binary_integer := 0;
begin
select count(*) count_matching_tbl dba_tables lower(table_name) = 'testtable';
if(count_matching_tbl = 0) execute immediate ( ' create table testtable (select a., b. tab1 join tab2 b on a.id = b.rid 1=2)'); end if; end;
if tab1 , tab2 table has same name column ambiguity occure while creating table , inserting record instead of * replace table column add in testtable like
create table testtable (select a.cola1, b.colb1 tab1 join tab2 b on a.id = b.rid 1=2
Comments
Post a Comment