Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Databases Creating and Modifying Database Tables Creating and Modifying Database Tables Altering Tables

YURI PAPINIAN
YURI PAPINIAN
11,838 Points

How to rename a column name?

How to rename a column name?

1 Answer

It's called an alias. Here alias_name will be the renamed column:

SELECT column_name AS alias_name FROM table_name;

This answer is actually using a select statement. While this will alias the column to whatever you want, it's only temporary and only used for that select query.

To completely rename a column it appears SQLite did not support this until recently. In our practice environment, you'll have to copy the instructions in this link under "The old way to rename column".

Remember, every SQL software could be slightly different on this so Google will be your best friend. In our environments it appears the 'alter table name rename' does not work and you'll have to drop and re-add the table.