Home > Database > Mysql Tutorial > How to Create an Empty Oracle Table with the Same Structure as Another?

How to Create an Empty Oracle Table with the Same Structure as Another?

Mary-Kate Olsen
Release: 2025-01-04 05:05:39
Original
459 people have browsed it

How to Create an Empty Oracle Table with the Same Structure as Another?

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;
Copy after login

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:

  • Excluded Elements: Sequences, triggers, indexes, some constraints, and materialized view logs are not copied to the new table.
  • Partitions: Handling partitioned tables requires a different strategy.

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template