Home >Database >Mysql Tutorial >How to Create an Oracle Table Copy with Only the Structure?

How to Create an Oracle Table Copy with Only the Structure?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-12-30 10:42:17858browse

How to Create an Oracle Table Copy with Only the Structure?

Creating an Oracle Table Copy Sans Data

One can easily duplicate an Oracle table's structure and data using the statement:

create table xyz_new as select * from xyz;

However, scenarios may arise where only the table's structure is desired.

Solution:

To create a table copy with just the structure, simply employ a WHERE clause that excludes all rows:

create table xyz_new as select * from xyz where 1=0;

Limitations:

Note that this method excludes the copying of certain elements:

  • Sequences
  • Triggers
  • Indexes
  • Some constraints
  • Materialized view logs
  • Partitions are not handled

This approach provides a quick and convenient means of creating a table structure clone without replicating its data.

The above is the detailed content of How to Create an Oracle Table Copy with Only the Structure?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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