简体   繁体   中英

how to select dynamically in select * from <table_name> partiton (Partition name)?

i have a big table with several partition. my partition name is like below:

P_13931203
P_13931204
P_13931205
P_13931206

i have a select for create partition name dynamically as below:

select 'P_' || to_char(sysdate-1,'yyyymmdd','nls_calendar=persian') from dual;
example Output: P_13931204

when i select as below everything is OK:

select *
from <table_name> partition (P_13931205);

but when i select as below i get error:

select *
from <table_name> partition (select 'P_' || to_char(sysdate-1,'yyyymmdd','nls_calendar=persian') from dual);

error:

ORA-00933: SQL command not properly ended 00933. 00000 - "SQL command not properly ended" *Cause:
*Action: Error at Line: 2 Column: 28 syntax error, expected : identifier

Try this:-

select * from partition 
(select 'P_' || to_char( sysdate-1,'yyyymmdd','nls_calendar=persian') from dual
) Dummy_table;

Beacuse after every sub-query select you have to mention a dataset name.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM