MySQL Forums
Forum List  »  Newbie

Create a table using LIKE
Posted by: Sin O'B
Date: May 20, 2005 10:59AM

Hello

I am breaking up a large table into months. I need a statement that will create a table based on another table. The table I'm creating needs to have exactly the same column names and column definitions as the original. It should not however copy over any of the original table's rows.

To add to the difficulty I have limited access to the database and mysql is not installed on my machine.(Talk about the blind leading the blind) Only the Systems admin has permissions to create/delete/edit tables.

I have passed to him a number of statements to run along the lines of the following :
CREATE TABLE IF NOT EXISTS reports_extra_08_2005 LIKE reports_extra;
CREATE TABLE IF NOT EXISTS reports_extra_09_2005 LIKE reports_extra;
CREATE TABLE IF NOT EXISTS reports_extra_10_2005 LIKE reports_extra;
and so on.....

However I have been informed by him that this is an invalid sql statement. He will not tell me why. I have looked online and can not find what is wrong with it.

I know I could go the long way and declare each column name & definition for each table individually, however there are a large number of very large tables to be broken down into months so something shot and sweet would be a distinct advantage.

Any help/advice would be greatly appreciated.

Thank you

Options: ReplyQuote


Subject
Written By
Posted
Create a table using LIKE
May 20, 2005 10:59AM
May 20, 2005 11:30AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.