Creating a query from a table

In Sql server I can create a table dynamically using a select into statement from another table. So basically the target table ends up having the exact same column names as the source table. So my "MY_NEW_TABLE" is created dynamically.

Question : How do I do the exact same thing in Oracle?

Example: Sql Server :  SELECT * INT MY_NEW_TABLE FROM MY_EXISTING_TABLE;
LVL 2
brgdotnetcontractorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Pawan KumarDatabase ExpertCommented:
>>Question : How do I do the exact same thing in Oracle?

Please use this in oracle

CREATE TABLE MY_NEW_TABLE  AS 
(SELECT * FROM MY_EXISTING_TABLE);

Open in new window


Please read more about this command from - https://www.techonthenet.com/oracle/tables/create_table2.php

TEST CASE-

CREATE TABLE MY_EXISTING_TABLE
(
	 CategoryId INT
	,CategoryName VARCHAR2(100)
)\\

INSERT INTO MY_EXISTING_TABLE VALUES(1,'Product')\\
INSERT INTO MY_EXISTING_TABLE VALUES(2,'Service')\\


CREATE TABLE MY_NEW_TABLE  AS 
(SELECT * FROM MY_EXISTING_TABLE)\\

select * from MY_NEW_TABLE\\

Open in new window

OUTPUT

 	CATEGORYID	CATEGORYNAME
1	1	Product
2	2	Service

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
brgdotnetcontractorAuthor Commented:
Thanks !
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.