Create Temporary table from Select statement

What would be the equivalent in Oracle for this MSSQL statement:

SELECT data1 INTO newtable FROM table1.

I haven't worked with MSSQL in a while, in this also correct?

SELECT column1 FROM table1 INTO #t1?

Thank you.
Horalia RodriguezIT DeveloperAsked:
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.

sdstuberCommented:
insert into new_table  select data1 from table1;


oracle needs the NEW_TABLE to be precreated,  oracle does not create temp tables on the fly.

You "can" do it, but unlike MSSQL where that is common and recommended.  In oracle that is NOT a recommended process.
0
slightwv (䄆 Netminder) Commented:
They are not temporary:
create newtable as
SELECT data1 FROM table1;

You would need to drop it when you are done with it.

If you need to use a temporary table, you create a global temporary table once and keep using it over and over again.  Only the session that inserts data into it can actually see the data.
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
Horalia RodriguezIT DeveloperAuthor Commented:
Thank you.
0
Mark GeerlingsDatabase AdministratorCommented:
"What would be the equivalent in Oracle for this MSSQL statement:

 SELECT data1 INTO newtable FROM table1."

In Oracle, you can likely drop the "INTO newtable" part of that statement.  Oracle supports simply selecting what you want from the table(s) you want, regardless of insert, update or delete activity that may be happening in the table(s).  Oracle will give you a "read consistent" result set from the instant in time that your query was submitted.  You will only see data that was already committed at that point in time.

As others indicated, Oracle supports "global temporary tables".  In some (rare) cases, these can be helpful, but they aren't created (nor dropped) "on-the-fly" like temporary tables in SQL Server.
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.