Creating a table from a query using a different tablespace (Oracle SQL)
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;
How can I create a copy of an Oracle table without copying the data?
Just use a where clause that won't select any rows:
create table xyz_new as select * from xyz where 1=0;
Limitations
The following things will not be copied to the new table:
- sequences
- triggers
- indexes
- some constraints may not be copied
- materialized view logs
This also does not handle partitions
How to get all tablespaces that a table belongs to in Oracle?
Ok, here it is:
The entire concept of "all the tablespaces that are assigned to a table" is a nullity. A table can belong to one and only one tablespace.
spo demo.log
select owner,
segment_name,
segment_type,
tablespace_name
from dba_segments
order by owner,
segment_name,
segment_type,
tablespace_name
;
spo off
edit demo.log
Related Topics
Case and Coalesce Short-Circuit Evaluation Works with Sequences in Pl/SQL But Not in SQL
Referencing a Composite Primary Key
How to Get a Real Time Within Postgresql Transaction
How to Insert Data to SQL Server Table Using R
Sort by Day of The Week from Monday to Sunday
Rails Order by Association Field
Running a SQLite3 Script from Command Line
Query to Find All Fk Constraints and Their Delete Rules (Sql Server)
Query to Convert from Datetime to Date MySQL
Any Disadvantages to Bit Flags in Database Columns
Passing a Dataframe List to a Where Clause in a SQL Query Embedded in R
SQL - Subquery in Aggregate Function
How to Use T-SQL Full-Text Search to Get Results Like Google
Convert Datetime to Unix Timestamp
Ora-06502: Pl/Sql: Numeric or Value Error: Character String Buffer Too Small