-2

I try to rename the table 'folks' to 'users'. How does it work?

Black
  • 18,150
  • 39
  • 158
  • 271
  • 1
    Your question name does not match your description. – james_bond Dec 11 '16 at 14:01
  • Thanks for the hint, sorry. – Black Dec 12 '16 at 08:40
  • Poor try to get some rep with a simple question that has been asked back in the stoneage already. You have a gold badge and > 1k rep. You are experienced enough to know that this kind of duplicate question asking + self-answering is not how Stackoverflow works. – Daniel W. Dec 12 '16 at 09:07
  • @DanFromGermanylol, first of first, i was searching if the question exists, but nothing came up. Second it is even desired from SO to answer own questions Q&A style. Go ahead and create a new question and look what the text on the bottom says. "Answer your own question – share your knowledge, Q&A-style" – Black Dec 12 '16 at 09:31

2 Answers2

1

In this case you can use ALTER TABLE with RENAME TO.

Syntax:

ALTER TABLE <Tablename>
RENAME TO <new Tablename>;

Example:

ALTER TABLE folks
RENAME TO users;
Graham
  • 7,431
  • 18
  • 59
  • 84
Black
  • 18,150
  • 39
  • 158
  • 271
0

If you want to rename the column and also change its type

ALTER TABLE [TableName] CHANGE [Column] [ColumnName] [New type];

For example:

ALTER TABLE folks CHANGE FolkAddress Address VARCHAR(1024);
james_bond
  • 6,778
  • 3
  • 28
  • 34