Create Table Structure From Existing Table in Oracle SQL

Do you need the same table structure as an existing table in your database, but empty of rows? Oracle SQL’s CREATE TABLE AS statement achieves this easily. Continue reading and learn how with a simple example…


Self-Promotion:

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!


I have this FRIENDS table that I want to duplicate:

DESC FRIENDS;
Description of the example FRIENDS table.
SELECT COUNT(*) FROM FRIENDS;

However, the FRIENDS table has 7 rows of data and I want the clone table to be empty.


Code, content, and community for developers.

The LAMP stack and the PHP technologies and frameworks it runs.


CREATE TABLE AS

Using SELECT * – or explicitly listing the individual columns you need – in a CREATE TABLE AS command with a WHERE clause predicate that evaluates to FALSE, creates a table based on the FROM clause table of the SELECT statement, but will not fill it with rows:

CREATE TABLE SAME_FRIENDS AS
(SELECT * FROM FRIENDS
WHERE 1 = 2);

Viewing the newly created SAME_FRIENDS table description, we can see it has the same structure as the FRIENDS table it is based on:

DESC SAME_FRIENDS;
Table structure of the SAME_FRIENDS table.

Are you a Medium member? If so, receive an email notification each time I publish a blog post if you prefer the Medium platform. Not a member? No worries! Use my sign-up link (I will get a commission at no extra cost to you) and join. I really enjoy reading all the great content there and I know you will too!!!


Querying the SAME_FRIENDS table shows there are no rows present in the table:

SELECT COUNT(*) FROM SAME_FRIENDS;
No rows present in the SAME_FRIENDS clone table.

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!


This is a quick and simple way you can essentially duplicate a table’s exact structure, without populating it with any rows.

As always, if you have any questions or see any mistakes in the code, please let me know via the comments. Constructive comments help me provide accurate blog posts and are much appreciated.

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 posts/technical writing I have completed for clients.



To receive email notifications (Never Spam) from this blog (“Digital Owl’s Prose”) for the latest blog posts as they are published, please subscribe (of your own volition) by clicking the ‘Click To Subscribe!’ button in the sidebar on the homepage! (Feel free at any time to review the Digital Owl’s Prose Privacy Policy Page for any questions you may have about: email updates, opt-in, opt-out, contact forms, etc…)

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.

Hey thanks for commenting! Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.