-1

Possible Duplicate:
How do I quickly rename a mysql database (change schema name)?

i have a database in mysql5 with some tables .

i want to rename it. i know the alter statement can be used to renaming tables but i don't know if it is true about database renaming or not.

Community
  • 1
  • 1
hd.
  • 16,676
  • 43
  • 110
  • 160
  • Agree with @Pekka voted to close as duplicate – Shakti Singh Apr 06 '11 at 13:42
  • @Shakti & Pekka: thank you. i read it and get the way to rename my database, but i think maybe it is better no close my question.because as you see there are someone who think using RENAME DATABASE is the solution and aren't aware of its removing. – hd. Apr 06 '11 at 13:48

1 Answers1

2

MySQL documentation states:

However, use of this statement could result in loss of database contents, which is why it was removed. Do not use RENAME DATABASE in earlier versions in which it is present.

And offers the alternative: ALTER DATABASE Syntax

Also, you can read about other options that have previously been explain here on SO.

Community
  • 1
  • 1
acm
  • 6,398
  • 3
  • 37
  • 44
  • 4
    -1 Read this article it says not to use. Read it before linking to your answer – Shakti Singh Apr 06 '11 at 13:35
  • @andre: thank you but mysql gives me an error by running those query. – hd. Apr 06 '11 at 13:36
  • 2
    He already know alternate read question again he wan't to know if that is safe or not? – Shakti Singh Apr 06 '11 at 13:40
  • @Shakti: It does not say that. He says he knows about `ALTER TABLE` but doesn't know about an equivalent for databases, be it `RENAME DATABASE`, `ALTER DATABASE` or otherwise. – Lightness Races in Orbit Apr 06 '11 at 13:46
  • @Shakti, I do not use MySQL for some time, I knew `RENAME DATABASE` could be used but didn't knew about the problems, that's why I blindly copied it. Anyways, it's a fact that OP is talking about tables and not databases when referring the alter statement. – acm Apr 06 '11 at 13:49
  • @all : thank you i got my answer.please be more kind to each other ;) – hd. Apr 06 '11 at 13:52
  • I just wanted to point only the thing we should think before posting our answer what we are posting and how much it is correct. Anyway no need to argue anymore. Cheers!. Taken back the downvote – Shakti Singh Apr 06 '11 at 14:59
  • 1
    @Shakti, I believe arguing using facts improve answers. I don't mind if you prove me wrong in each of my other answers. So, now I know I shouldn't be using RENAME next time I need it. :-) – acm Apr 06 '11 at 15:07