There are a number of reasons why you may need to rename a table in your SQL Database. Whatever the case may be, the process is super-easy. In this post, I share 2 different ways you can rename an existing table in the Oracle Database. Continue reading and learn how…
If you enjoy the content written here, by all means, share this blog and your favorite post(s) with others who may benefit from or like it as well. Since coffee is my favorite drink, you can even buy me one if you would like!
If you like SQL and PHP-related content, consider signing up for my weekly email. Use either the form at the bottom of the page or this link. Thank you!
I am using Oracle SQL for the examples in this post. Most SQL implementations should have similar ALTER TABLE syntax but be sure and check your RDBMS’s documentation for specifics.
Rename Table With ALTER TABLE DDL Command
I have a simple one-column table, NAMES, that I want to rename:
In order to change the name of a table, you use the SQL ALTER TABLE DDL command. ALTER TABLE syntax is straightforward when renaming a table:
Using the DESC command, we can see nothing else changed with the table but the name (now named FIRST_NAMES). The same FIRST_NAME column is still there:
Consider making a donation as I continue to provide valuable content here on my blog. Thank you so much!!! Every bit is much appreciated and helps tremendously!
Rename Table in Oracle SQL Developer
It is also quite easy to rename an existing table using the Oracle SQL Developer IDE.
Start by right-clicking the table you want to rename in the Tables pane of Oracle SQL Developer and click Edit from the menu:
Upon clicking Edit, the visual dialogue interface shown below opens. The 2nd field from the top is the Name field and displays the current table name:
Input the new table name in the Name field section. In this example, I am choosing IMPORTANT_NAMES as the new table name. Be sure and click the OK button at the bottom to hold the changes:
To confirm the action was successful, revisit the Tables pane where you can see the renamed table.
Shown in the below screenshot, the table formally named FIRST_NAMES has been renamed to IMPORTANT_NAMES:
And there are 2 examples of how you can rename an existing table in your Oracle Database. If you have any questions or see any problems in the code, please add a comment. Thank you.
Like what you have read? See anything incorrect? Please comment below and thank you for reading!!!
A Call To Action!
Thank you for taking the time to read this post. I truly hope you discovered something interesting and enlightening. Please share your findings here, with someone else you know who would get the same value out of it as well.
Visit the Portfolio-Projects page to see blog post/technical writing I have completed for clients.
Be sure and visit the “Best Of” page for a collection of my best blog posts.
Josh Otwell has a passion to study and grow as a SQL Developer and blogger. Other favorite activities find him with his nose buried in a good book, article, or the Linux command line. Among those, he shares a love of tabletop RPG games, reading fantasy novels, and spending time with his wife and two daughters.
Disclaimer: The examples presented in this post are hypothetical ideas of how to achieve similar types of results. They are not the utmost best solution(s). The majority, if not all, of the examples provided, are performed on a personal development/learning workstation-environment and should not be considered production quality or ready. Your particular goals and needs may vary. Use those practices that best benefit your needs and goals. Opinions are my own.
One thought on “How to Rename an SQL Table”