Creating an Oracle Table Copy Without Data Replication
The need arises to create a duplicate table with the same structure but without the actual data. While the typical approach is to use a straightforward select statement, this can be inefficient if data duplication is undesirable.
Solution: Copying Table Structure Only
To achieve the desired result, employ a method that leverages a WHERE clause to eliminate row selection. Consider the following query:
create table xyz_new as select * from xyz where 1=0;
By using the condition "1=0," no rows are retrieved from the source table, essentially creating an empty table with the same structure as the original.
Limitations:
However, it's important to note that this approach has some limitations:
The above is the detailed content of How to Create an Empty Oracle Table with the Same Structure as Another?. For more information, please follow other related articles on the PHP Chinese website!