Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a table from a query using a different tablespace (Oracle SQL)

Tags:

sql

oracle

toad

I want to create some tables in our database from some queries I have developed. I used the code below and it created the table and it works great.

The issue I am having is apparently it created the table using a different tablespace than the one we are supposed to use. Is there a way to specify that in code like what is below? Just a disclaimer, I am more of the end user of the data so I am not as tech savy.

CREATE TABLE new_permanent_table
AS
SELECT *
FROM old_temporary_table
WHERE amount<5000;
like image 783
user1723699 Avatar asked Dec 16 '13 20:12

user1723699


People also ask

How will you create a table with the same structure as another table in Oracle?

Question: How can I create an Oracle table from another table without copying any values from the old table? Answer: To do this, the Oracle CREATE TABLE syntax is: CREATE TABLE new_table AS (SELECT * FROM old_table WHERE 1=2);


1 Answers

Assuming that you have a quota on the other tablespace, you should be able to just add the "TABLESPACE <tablespace name>" statement below your CREATE TABLE statement:

CREATE TABLE new_permanent_table
TABLESPACE other_tablespace
AS
SELECT *
FROM old_temporary_table
WHERE amount<5000;
like image 107
roartechs Avatar answered Oct 09 '22 15:10

roartechs