1

These SQLs should be give same result? Second one gives an error (SQL Error 1064).

Correct :          ALTER TABLE table1 TRUNCATE PARTITION d20; 
Does not work   :  ALTER TABLE table1 TRUNCATE PARTITION concat('d', '20');

Actually I stuck on truncate table with respect to day of month, (ie today is 25th) execute

i was planned sql like below, but does not work

ALTER TABLE table1 TRUNCATE PARTITION DAYOFMONTH(now());

1 Answer 1

1

No, they shouldn't. TRUNCATE PARTITION accepts a partition name, which is not a string.

UPD:

You still can create and perform dynamic sql queries using PREPARE + EXECUTE

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks this is sol'n for problem but I have a constraint. SQL should be simple that only one line (statement). If it is possible done by one step i am very glad
@erdinc: unfortunately it is not. Only dynamic sql.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.